[Qt-interest] Drawing rectangular
Ulf-Alexander v. Ceumern-Lindenstjerna
ceumern at vrmagic.com
Mon Sep 21 14:57:59 CEST 2009
I don't get it. If you already have a QTextBrowser, why do you want to manually paint text onto it?
QTextBrowser is made for displaying text and you should not have to paint the text yourself.
If you want to paint everything yourself just subclass a plain QWidget and do everything by hand.
Regards, Ulf
Ps:
Also, I suggest you read a good book about Qt programming or do the online tutorials, since your questions indicate that you have not done much work with Qt yet and literature and the tutorials are always a good place to start.
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of Yuvaraj R
> Sent: Monday, September 21, 2009 2:00 PM
> To: Samuel Rødal
> Cc: qt-interest
> Subject: Re: [Qt-interest] Drawing rectangular
>
> Thanks redal
>
> I am going towards my goal..
>
> I want to paint the paticular text of text browser..
>
>
> How can i acheive this one
>
>
> Thanks
>
> Yuvaraj R
>
>
> On Mon, Sep 21, 2009 at 4:17 PM, Samuel Rødal <sroedal at trolltech.com>
> wrote:
>
>
> Yuvaraj R wrote:
>
>
> still i am not getting
>
> i am getting following things in log
>
>
> QPainter::begin: Paint device returned engine == 0, type: 1
>
> QPainter::drawRects: Painter not active
>
> QPainter::end: Painter not active, aborted
>
> QPainter::setPen: Painter not active
>
> QPainter::drawRects: Painter not active
>
>
> Thanks
>
>
> Yuvaraj R
>
>
> To call the base class paint event, your text browser
> class' paint
> event should look like this:
>
>
> void text_browser::paintEvent(QPaintEvent *e)
> {
> QTextBrowser::paintEvent(e);
> QPainter painter;
> painter.setPen(Qt::red);
> painter.drawRect(100,100,100,100);
> }
>
> I don't think calling accept() makes any difference for
> paint events.
>
> --
> Samuel
>
>
>
>
> Right, that should have been QPainter painter(this); and not just
> QPainter painter;
>
> But another problem is that QTextBrowser is an abstract scroll
> area, which means that its paint event actually paints into the
> viewport widget, not into the widget itself.
>
> Try "QPainter painter(viewport());" instead.
>
> Refer to
> http://doc.trolltech.com/4.5/qabstractscrollarea.html#details for more
> information on QAbstractScrollArea.
>
> --
> Samuel
>
>
More information about the Qt-interest-old
mailing list