Hi,
I want to draw a QRectF on my graphicsScene, but I don't know why it doesn't work.
void myScene
::drawBackground ( QPainter * painter,
const QRectF & rect
) {
QRectF rec
(m_startRectPoint, getCursorScenePos
/*this function works perfectly*/());
painter
->setPen
(QPen(Qt
::black,
1, Qt
::DashLine));
painter->drawRect(rec);
update();
//QGraphicsScene::drawForeground(painter, rect);
}
void myScene::drawBackground ( QPainter * painter, const QRectF & rect )
{
QRectF rec(m_startRectPoint, getCursorScenePos/*this function works perfectly*/());
painter->setPen(QPen(Qt::black, 1, Qt::DashLine));
painter->drawRect(rec);
update();
//QGraphicsScene::drawForeground(painter, rect);
QGraphicsScene::drawBackground(painter, rect);
}
To copy to clipboard, switch view to plain text mode
I want to draw a rectangle which starts in "m_startREctPoint" and finishes in the mouse pointer, at each moment (I did similar things using paint event in the QGraphicsItems).
Am I doing something wrong there?
EDIT: I forgot to say something, if you minimize and maximize the widow it paints it well, as expected.
thanks!
Bookmarks