[Qt-interest] Drawing rectangular
Yuvaraj R
yuvaraj at ongobiz.com
Mon Sep 21 12:11:13 CEST 2009
Hi
I have overrrided the QTextBrowser class like
*text_browser.h*
#ifndef TEXT_BROWSER_H
#define TEXT_BROWSER_H
#include <QTextBrowser>
#include <QPaintEvent>
class text_browser:public QTextBrowser
{
public:
text_browser(QWidget *parent=0);
void paintEvent(QPaintEvent *e);
};
#endif // TEXT_BROWSER_H
*text_browser.cpp*
#include "text_browser.h"
#include <QMessageBox>
text_browser::text_browser(QWidget *parent):QTextBrowser(parent)
{
}
void text_browser::paintEvent(QPaintEvent *e)
{
e->accept();
}
you told that call base class paint event to paint the text browser.
any mistake is there in derived class of text_browser.
Sorry English is not my first language .
Thanks
Yuvaraj R
On Mon, Sep 21, 2009 at 3:25 PM, Yuvaraj R <yuvaraj at ongobiz.com> wrote:
> Thanks for your reply
>
> As per you ,
>
> I need to over ride the paintEvent of TextBrowser ?
>
>
> Thanks
>
> Yuvaraj R
>
>
> On Mon, Sep 21, 2009 at 3:26 PM, Samuel Rødal <sroedal at trolltech.com>wrote:
>
>> 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
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090921/2a6cc447/attachment.html
More information about the Qt-interest-old
mailing list