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
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