How can i write a text background of my treewidget using QPainter?
I am using QT 4.5...
How can i write a text background of my treewidget using QPainter?
I am using QT 4.5...
do you need to change text color?
I don't understand what you want.
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
i want to show a text background-treewidget. Not color.
still don't understand.
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
QPainter p;
p.begin( tree_widget );
p.drawText( 5, 60, QString("Something"));
p.end();
i wrote this code but it`s not worked .
ERORR:
QPainter::begin: Widget painting can only begin as a result of a paintEvent
QPainter::end: Painter not active, aborted
you must draw in QWidget:: paintEvent.
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
void QWidget:aintEvent(QPaintEvent *)
{
QPainter p;
p.begin( tree_widget );
p.drawText( 5, 5, QString("Something"));
p.end();
}
ERROR:
The program has unexpectedly finished.
cool!
if you want to draw on a tree widget you must:
-- subclass QTreeWidget/QTreeView and reimplement paintEvent;
-- install event filter on a tree widget and process QPaintEvent.Qt Code:
... { //drawing stuff } ...To copy to clipboard, switch view to plain text mode
Qt Code:
... m_treeWidget->viewport()->installEventFilter(this); ... { //draw stuff } }To copy to clipboard, switch view to plain text mode
Last edited by spirit; 29th April 2009 at 15:16.
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
Sorry, i don`t understand .
have you got an example code about this problem?
I updated a post above.
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
thanks.. it`s worked...
how can i refresh this event filter or painter?
Now it`s working when programme started.
do you mean how to chage a text which will be drawn?
have a look at example which is located in QTDIR/examples/widgets/wiggly.
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
Bookmarks