[Qt-interest] Drawing rectangular

Yuvaraj R yuvaraj at ongobiz.com
Mon Sep 21 14:00:10 CEST 2009


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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090921/e3b52fd6/attachment.html 


More information about the Qt-interest-old mailing list