Results 1 to 5 of 5

Thread: QT 4.6.2 QGraphicsView paintEvent() not able to be triggered by update()/repaint() ?

  1. #1
    Join Date
    Sep 2009
    Location
    Surrey, BC, Canada
    Posts
    110
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QT 4.6.2 QGraphicsView paintEvent() not able to be triggered by update()/repaint() ?

    Hi, all:

    My Environment:
    OS: Ubuntu 10.04 Lucid
    Qt: 4.6.2


    I inherited QGraphicsView, and designed my own class (qtImageView.h)

    Qt Code:
    1. class CqtImageView : public QGraphicsView
    2. {
    3. Q_OBJECT
    4.  
    5. private:
    6. QGraphicsScene* m_QTGraphicsScene;
    7. QImage* m_QTImage;
    8.  
    9. protected:
    10. void paintEvent(QPaintEvent *event);
    11.  
    12. public:
    13. CqtImageView( QWidget *parent = 0 );
    14. virtual ~CqtImageView( );
    15. void putImage(const Mat& image);
    16. ...
    17. };
    To copy to clipboard, switch view to plain text mode 


    in qtImageView.cpp:

    Qt Code:
    1. CqtImageView::CqtImageView(QWidget *parent): QGraphicsView(parent)
    2. {
    3. this->m_QTGraphicsScene = new QGraphicsScene;
    4. this->setScene( this->m_QTGraphicsScene );
    5. }
    6.  
    7. CqtImageView::~CqtImageView( )
    8. {
    9. if(this->m_QTImage) delete (this->m_QTImage);
    10. if(this->m_QTGraphicsScene) delete (this->m_QTGraphicsScene);
    11. }
    12.  
    13. void CqtImageView::putImage(const Mat& img)
    14. {
    15. ... // This part is to assign the image data from img to this->m_QTImage
    16. this->m_QTGraphicsScene->invalidate();
    17. this->m_bIsDrawing = true;
    18. this->update(); // or this->repaint();
    19. }
    20.  
    21. void CqtImageView::paintEvent(QPaintEvent *event)
    22. {
    23. if(this->m_bIsDrawing)
    24. {
    25. QPainter p(this->viewport()); // breakpoint 1
    26. p.drawImage(QPoint(0,0),*m_QTImage); // breakpoint 2
    27. this->m_bIsDrawing = false; // breakpoint 3
    28. }
    29. }
    To copy to clipboard, switch view to plain text mode 


    However, whenever my program called
    putImage(const Mat& img)
    ,
    I was thinking
    this->update(); // or this->repaint();
    will instantaneously trigger
    CqtImageView:aintEvent
    , but even after I created three breakpoints at each line in
    CqtImageView:aintEvent
    , my program never stopped on those breakpoints.

    Can anybody please help? This is seriously urgent.
    And, it seems only QT 4.6.2 brings me this issue.
    My code seems to work fine when using QT 4.5


    Best Regards
    JIA
    Last edited by jiapei100; 9th June 2010 at 19:58. Reason: updated contents
    Welcome to Vision Open
    http://www.visionopen.com

  2. #2
    Join Date
    Mar 2009
    Location
    Tennessee, US
    Posts
    41
    Thanks
    3
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QT 4.6.2 QGraphicsView paintEvent() not able to be triggered by update()/repaint(

    I have had some weird GUI issues with 4.6.2 myself. I recently upgraded to 4.6.3 which came out the other day. It seemed to fix all of the weird GUI issues. I would recommend upgrading.

  3. #3
    Join Date
    Sep 2009
    Location
    Surrey, BC, Canada
    Posts
    110
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QT 4.6.2 QGraphicsView paintEvent() not able to be triggered by update()/repaint(

    Hi, amoswood:

    Thank you so much for your prompt reply.
    Are you using Windows or Ubuntu?
    Default Ubuntu repository is still using 4.6.2 and if I remove all qt packages of version 4.6.2, loads of other important packages will be removed meanwhile.
    This is not what I expected.
    How to upgrade from qt 4.6.2 to 4.6.3 without disturbing other packages which rely on qt-dev libraries?

    Best Regards
    JIA
    Welcome to Vision Open
    http://www.visionopen.com

  4. #4
    Join Date
    Mar 2009
    Location
    Tennessee, US
    Posts
    41
    Thanks
    3
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QT 4.6.2 QGraphicsView paintEvent() not able to be triggered by update()/repaint(

    Quote Originally Posted by jiapei100 View Post
    How to upgrade from qt 4.6.2 to 4.6.3 without disturbing other packages which rely on qt-dev libraries?
    4.6.2 and 4.6.3 are binary compatible DLLs or SOs. So, you can simply replace the SOs in the Qt installation with some that you download from Qt. You don't have to re-compile or anything. All of this is assuming that you are not linking statically with Qt.

  5. #5
    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: QT 4.6.2 QGraphicsView paintEvent() not able to be triggered by update()/repaint(

    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.


Similar Threads

  1. Paintevent and update
    By csvivek in forum Qt Programming
    Replies: 1
    Last Post: 25th March 2008, 07:09
  2. Calling update() from paintEvent()
    By wonder.mice in forum Qt Programming
    Replies: 8
    Last Post: 11th January 2008, 13:41
  3. Replies: 5
    Last Post: 18th April 2007, 10:29
  4. Use of repaint/update
    By Placido Currò in forum Qt Programming
    Replies: 3
    Last Post: 3rd April 2007, 19:24
  5. Replies: 1
    Last Post: 13th July 2006, 21:10

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.