Hi Every body ,
I am porting my application fron QT3.3 to QT4.5. In my application all the paintings are done on viewport widget of QScrollView(Q3ScrollView in support class). In this application virtual function paintEvent is not implemented. I am trying to port this code to QT4.5 which require all the paintings done in paintEvent function. For the time being i don't want to change my code much so i am using : Qt::WA_PaintOutsidePaintEvent flag. I running my application on Linux but some how this flag is showing expected effect.
Following is pseudo code :
QucsView
::QucsView(QWidget *parent
) : Q3ScrollView
(parent
) // Constructor{
setVScrollBarMode(Q3ScrollView::AlwaysOn);
setHScrollBarMode(Q3ScrollView::AlwaysOn);
viewport()->setPaletteBackgroundColor(QucsSettings.BGColor);
viewport()->setMouseTracking(true);
viewport()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true);
}
void QucsView
::MMoveWire2(QMouseEvent *Event
) // Called on movement of mouse // Basically drawing a line on mouse movement
{
setAttribute(Qt::WA_PaintOutsidePaintEvent, true);
painter.setPen(Qt::DotLine);
painter.
setCompositionMode(QPainter::RasterOp_NotSource);
painter.drawLine(----);
}
QucsView::QucsView(QWidget *parent) : Q3ScrollView(parent) // Constructor
{
setVScrollBarMode(Q3ScrollView::AlwaysOn);
setHScrollBarMode(Q3ScrollView::AlwaysOn);
viewport()->setPaletteBackgroundColor(QucsSettings.BGColor);
viewport()->setMouseTracking(true);
viewport()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true);
}
void QucsView::MMoveWire2(QMouseEvent *Event) // Called on movement of mouse
// Basically drawing a line on mouse movement
{
setAttribute(Qt::WA_PaintOutsidePaintEvent, true);
QPainter painter(viewport());
painter.setPen(Qt::DotLine);
painter.setCompositionMode(QPainter::RasterOp_NotSource);
painter.drawLine(----);
}
To copy to clipboard, switch view to plain text mode
When i run this it give warning like
QPainter::setPen: Painter not active and it don't draw as expected....
This code is working completely fine with QT3.3 except PaintOutsidePaintEvent flag.
Any ideas what might be wrong here. I will be thankful for ur help
thx
shivam
Bookmarks