tom701
12th September 2010, 20:04
Dear All,
I need GUI to show correspondences between points from two images (a computer vision task). But I have problem drawing lines to connect these corresponding points. The QMdiArea has QScrollArea as sub-windows. The problem is: part of the lines drawn is always underneath the QScrollArea (the sub-window). Please see the attached figure, and the code to draw is shown below. How can I draw the lines on top of the sub-windows of QMdiArea? Thank you for help!
Header:
class QMyMdiArea : public QMdiArea
{
Q_OBJECT
public:
explicit QMyMdiArea(QWidget *parent = 0);
bool eventFilter(QObject *o, QEvent *e);
protected:
void paintEvent(QPaintEvent*);
};
Implementation:
void QMyMdiArea::paintEvent(QPaintEvent* pe)
{
QMdiArea::paintEvent(pe);
QPainter p(this->viewport());
p.setPen(Qt::red);
QPointF pt1;
QPointF pt2;
p.drawLine(pt1, pt2);
}
bool QMyMdiArea::eventFilter(QObject *o, QEvent *e)
{
if(qobject_cast<QMdiSubWindow*> (o)!=0 && e->type()==QEvent::Move)
viewport()->update();
return false;
}
I need GUI to show correspondences between points from two images (a computer vision task). But I have problem drawing lines to connect these corresponding points. The QMdiArea has QScrollArea as sub-windows. The problem is: part of the lines drawn is always underneath the QScrollArea (the sub-window). Please see the attached figure, and the code to draw is shown below. How can I draw the lines on top of the sub-windows of QMdiArea? Thank you for help!
Header:
class QMyMdiArea : public QMdiArea
{
Q_OBJECT
public:
explicit QMyMdiArea(QWidget *parent = 0);
bool eventFilter(QObject *o, QEvent *e);
protected:
void paintEvent(QPaintEvent*);
};
Implementation:
void QMyMdiArea::paintEvent(QPaintEvent* pe)
{
QMdiArea::paintEvent(pe);
QPainter p(this->viewport());
p.setPen(Qt::red);
QPointF pt1;
QPointF pt2;
p.drawLine(pt1, pt2);
}
bool QMyMdiArea::eventFilter(QObject *o, QEvent *e)
{
if(qobject_cast<QMdiSubWindow*> (o)!=0 && e->type()==QEvent::Move)
viewport()->update();
return false;
}