Hi, all:
My Environment:
OS: Ubuntu 10.04 Lucid
Qt: 4.6.2
I inherited QGraphicsView, and designed my own class (qtImageView.h)
{
Q_OBJECT
private:
protected:
public:
CqtImageView
( QWidget *parent
= 0 );
virtual ~CqtImageView( );
void putImage(const Mat& image);
...
};
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);
...
};
To copy to clipboard, switch view to plain text mode
in qtImageView.cpp:
{
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();
}
{
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
}
}
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
}
}
To copy to clipboard, switch view to plain text mode
However, whenever my program called ,
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
Bookmarks