Results 1 to 7 of 7

Thread: QGraphicsScene::update can not work (arm embeded linux ubuntu)

  1. #1
    Join Date
    Oct 2013
    Posts
    8
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default QGraphicsScene::update can not work (arm embeded linux ubuntu)

    the same code about show my image and update image code in 2 Environment
    1. Desktop x86 ubuntu =>QT lib is 5.1.1
    2. embed linux(ubuntu) arm (Beaglebone Black) ==>QT lib 4.8.1

    use cross complier QT configure:
    ./configure -prefix /opt/qt-Arm-ubuntu -embedded arm -platform qws/linux-x86-g++ -xplatform qws/linux-arm-ubuntu -depths 16,24,32 -no-mmx -no-3dnow -no-sse -no-sse2 -no-glib -no-cups -no-largefile -no-accessibility -no-openssl -no-gtkstyle -fast -nomake demos -nomake examples -no-svg -no-phonon -no-qt3support -no-svg -qt-gfx-linuxfb -no-javascript-jit -confirm-license -opensource -no-webkit -little-endian -host-little-endian -qt-kbd-linuxinput -qt-mouse-linuxinput

    QGraphicsScene::update work in Desktop x86 ubunt but not work in embed linux(ubuntu) arm



    My code :

    MainWindow.h

    QImage* rawImg;
    QGraphicsView *usrView;
    QGraphicsScene* scene;
    uchar* rawData;
    uchar* rawDataTmp ;
    int rawW = 400;
    int rawH = 400;
    int rawW2 = 400;
    int rawH2= 200;

    MainWindow.cpp

    MainWindow::init()
    {
    rawData =(uchar*) malloc(rawW*rawH*4);
    rawDataTmp = rawData;
    while(rawDataTmp < (rawData+rawW*rawH*4))
    {
    *rawDataTmp = 0;
    rawDataTmp++;
    //g
    *rawDataTmp = 0xff;
    rawDataTmp++;
    //r
    *rawDataTmp = 0;
    rawDataTmp++;
    //a
    *rawDataTmp = 0;
    rawDataTmp++;
    }
    rawImg = new QImage(rawData,rawW,rawH,QImage::Format_RGB32);
    scene = new QGraphicsScene(this);
    scene->addPixmap(QPixmap::fromImage(*rawImg));
    usrView = new UsrGV(ui->centralWidget);
    usrView->setScene(scene);
    usrView->installEventFilter(this);
    }

    bool MainWindow::eventFilter(QObject *obj, QEvent *event)
    {
    if (event->type() == QEvent::MouseButtonPress )
    {
    rawDataTmp = rawData ;
    while(rawDataTmp < (rawData+rawW2*rawH2*4))
    {
    //b
    *rawDataTmp = 0xff;
    rawDataTmp++;
    //g
    *rawDataTmp = 0;
    rawDataTmp++;
    //r
    *rawDataTmp = 0xff;
    rawDataTmp++;
    //a
    *rawDataTmp = 0;
    rawDataTmp++;
    }
    scene->update();
    }
    }

    when i press mouse, in Desktop x86 ,i can see pink color ,but arm embeded linux only green

    does anyone can tell me why?
    and how can i refresh graphicsview in embed linux(ubuntu) arm

    Ps : i know create new scene and then setScene can refresh the graphicview but not good for me,
    my main project need to update image every 100 ms ==> it will cause mouse strange (move very slowly)

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsScene::update can not work (arm embeded linux ubuntu)

    Don't update the raw data without updating the QImage instance.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    louboutinoutlet (2nd December 2013)

  4. #3
    Join Date
    Oct 2013
    Posts
    8
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QGraphicsScene::update can not work (arm embeded linux ubuntu)

    Dear Master of Zen:
    thanks your reply.

    could you tell more detail about when i can update raw data?
    or give an example?

  5. The following user says thank you to xstream71 for this useful post:

    louboutinoutlet (2nd December 2013)

  6. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsScene::update can not work (arm embeded linux ubuntu)

    Quote Originally Posted by xstream71 View Post
    could you tell more detail about when i can update raw data?
    If you modify QImage's data behind its back, the scene might not get informed that the image has changed and does not refresh the item since the item works on a pixmap created from the image that contains no link to the image itself. You have to re-create the pixmap again and set it on the pixmap item in the scene.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. The following user says thank you to wysota for this useful post:

    louboutinoutlet (2nd December 2013)

  8. #5
    Join Date
    Oct 2013
    Posts
    8
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QGraphicsScene::update can not work (arm embeded linux ubuntu)

    Quote Originally Posted by wysota View Post
    If you modify QImage's data behind its back, the scene might not get informed that the image has changed and does not refresh the item since the item works on a pixmap created from the image that contains no link to the image itself. You have to re-create the pixmap again and set it on the pixmap item in the scene.
    Thanks.
    so i need remove old pixmap item from scene , and then add new ==>its work , but that's not good for me
    it cause my mouse move very slowly in embeded linux( my raw data will refresh every 100ms,if i refresh every 10sec it will be better ,but i cannot do that) , i don't know why.....

    I try use QImage::setPixel ,and set pixel finish do scene.update & grapgicview.update ==>but also not work
    could you tell what wrong ?

    code:

    MainWindow.cpp

    MainWindow::init
    {
    rawImg = new QImage(rawW,rawH,QImage::Format_RGB32);
    scene = new QGraphicsScene(this);

    QRgb value = qRgb(0,0xff,0);

    for(int i= 0; i<rawW;i++)
    {
    for(int j= 0; j<rawH;j++)
    {
    rawImg->setPixel(i,j,value);;
    }
    }
    scene->addPixmap(QPixmap::fromImage(*rawImg));



    usrView = new UsrGV(ui->centralWidget);
    usrView->setScene(scene);
    usrView->installEventFilter(this);
    }

    bool MainWindow::eventFilter(QObject *obj, QEvent *event)
    {
    if (event->type() == QEvent::MouseButtonPress )
    {
    QRgb value;
    value = qRgb(0xff,0,0xff);

    for(int i= 0; i<rawW;i++)
    {
    for(int j= 0; j<rawH2;j++)
    {
    rawImg->setPixel(i,j,value);;
    }
    }

    scene->update(0,0,rawW,rawH);
    usrView->update();


    }
    }

    i only see green color , can't see pink color

  9. The following user says thank you to xstream71 for this useful post:

    louboutinoutlet (2nd December 2013)

  10. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsScene::update can not work (arm embeded linux ubuntu)

    Basically converting between QImage and QPixmap is expensive. You also don't need to add a new item to the scene, you can reuse the old one and just set a new pixmap on it. setPixel() is also slow, it's much faster to use QImage::bits().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. The following 2 users say thank you to wysota for this useful post:

    louboutinoutlet (2nd December 2013), xstream71 (15th October 2013)

  12. #7
    Join Date
    Oct 2013
    Posts
    8
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QGraphicsScene::update can not work (arm embeded linux ubuntu)

    Thanks.
    It's ok.

  13. The following user says thank you to xstream71 for this useful post:

    louboutinoutlet (2nd December 2013)

Similar Threads

  1. Update QGraphicsScene - Best Practice
    By vinaykusta in forum Qt Programming
    Replies: 0
    Last Post: 4th November 2011, 05:52
  2. Ubuntu: Wno-deprecated does not work
    By Caius Aérobus in forum Qt Programming
    Replies: 0
    Last Post: 2nd February 2010, 15:08
  3. Can't manually update QGraphicsScene
    By aladagemre in forum Qt Programming
    Replies: 4
    Last Post: 17th January 2010, 22:52
  4. QGraphicsScene update?
    By Gurdt in forum Qt Programming
    Replies: 11
    Last Post: 17th April 2009, 10:03
  5. How to install Qt/Qtopia on embeded linux?
    By atil in forum Qt for Embedded and Mobile
    Replies: 7
    Last Post: 13th December 2007, 23:03

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.