[Qt-interest] QGraphicsView coordinates

Phil phillor at telstra.com
Wed Dec 17 06:07:18 CET 2008


On Tuesday 16 December 2008 21:46:24 Leonardo Bispo wrote:
> Hi,
>
> QFrame inherits QWidget, and QWidget inherits QPaintDevice, so you can
> create a painter to draw inside a paint device.
>
> I think what is wrong in your code is that you are passing two arguments to
> constructor
>
> QPainter paint(mapFrame,this);
>
> In documentation you must pass only the painter device or none
>
> QPainter ()
> QPainter ( QPaintDevice * device )
>
> http://doc.trolltech.com/4.4/qpainter.html
>
> There are many differences between Qt3 and Qt4. You must check all this
> differences.
>

Thanks for your reply Leonardo.

What you say is absolutely true but how do I now specifically request that the 
painting takes place on the frame and not on main window?  QPainter 
(frame_name) compiles but nothing is painted and QPainter (this) paints on the 
main window.

I know the following is a clue but but how do I force a painting event?

"QPainter::begin: Widget painting can only begin as a result of a paintEvent"

This is my paintEvent code:

void Pest::paintEvent(QPaintEvent *)
{
  QPainter paint(mapFrame);

  paintMap(&paint);  //this function draws the pixmap, draws a few points and      
draws text on the map.
}

The documentation has not helped at all, not this time anyway.

-- 
Regards,
Phil.



More information about the Qt-interest-old mailing list