[Qt-interest] Drawing rectangular
Samuel Rødal
sroedal at trolltech.com
Mon Sep 21 11:56:27 CEST 2009
Yuvaraj R wrote:
> QPainter paint();
>
> paint.begin(ui->textBrowser);
>
> paint.drawRect(100,100,100,100);
>
> paint.end();
>
>
> i tried with this code..
>
>
> is it correct ?
>
>
> I am not getting anything .
>
>
> Thanks
>
>
> Yuvaraj R
Painting on a widget needs to happen in that widget's paint event. In
this case you're trying to paint on ui->textBrowser. For this to work
you'd need to subclass QTextBrowser, reimplement its paintEvent(), call
the base class paint event to let QTextBrowser do its normal painting
operations, and finally do your own painting.
Btw, I also think you should remove the () in the "QPainter paint();"
line, or the compiler will treat it as a function forward declaration.
--
Samuel
More information about the Qt-interest-old
mailing list