PDA

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



jiapei100
9th June 2010, 19:56
Hi, all:

My Environment:
OS: Ubuntu 10.04 Lucid
Qt: 4.6.2


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



class CqtImageView : public QGraphicsView
{
Q_OBJECT

private:
QGraphicsScene* m_QTGraphicsScene;
QImage* m_QTImage;

protected:
void paintEvent(QPaintEvent *event);

public:
CqtImageView( QWidget *parent = 0 );
virtual ~CqtImageView( );
void putImage(const Mat& image);
...
};



in qtImageView.cpp:



CqtImageView::CqtImageView(QWidget *parent): QGraphicsView(parent)
{
this->m_QTGraphicsScene = new QGraphicsScene;
this->setScene( this->m_QTGraphicsScene );
}

CqtImageView::~CqtImageView( )
{
if(this->m_QTImage) delete (this->m_QTImage);
if(this->m_QTGraphicsScene) delete (this->m_QTGraphicsScene);
}

void CqtImageView::putImage(const Mat& img)
{
... // This part is to assign the image data from img to this->m_QTImage
this->m_QTGraphicsScene->invalidate();
this->m_bIsDrawing = true;
this->update(); // or this->repaint();
}

void CqtImageView::paintEvent(QPaintEvent *event)
{
if(this->m_bIsDrawing)
{
QPainter p(this->viewport()); // breakpoint 1
p.drawImage(QPoint(0,0),*m_QTImage); // breakpoint 2
this->m_bIsDrawing = false; // breakpoint 3
}
}




However, whenever my program called
putImage(const Mat& img),
I was thinking
this->update(); // or this->repaint(); will instantaneously trigger

CqtImageView::paintEvent, but even after I created three breakpoints at each line in

CqtImageView::paintEvent, 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

amoswood
9th June 2010, 23:01
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.

jiapei100
10th June 2010, 09:10
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

amoswood
10th June 2010, 13:39
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.

wysota
10th June 2010, 21:25
For reference: http://www.qtcentre.org/threads/31528-Qt-Upgrade-Repository..?p=147026#post147026