How can i write a text background of my treewidget using QPainter?
How can i write a text background of my treewidget using QPainter?
I am using QT 4.5...
Re: How can i write a text background of my treewidget using QPainter?
do you need to change text color?
I don't understand what you want.
Re: How can i write a text background of my treewidget using QPainter?
i want to show a text background-treewidget. Not color.
Re: How can i write a text background of my treewidget using QPainter?
still don't understand. :)
Re: How can i write a text background of my treewidget using QPainter?
If I get you, you want a text as a background. Then use a QPainter to create a QPixmap with your favored text and set that QPixmap as a background image.
Re: How can i write a text background of my treewidget using QPainter?
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
Re: How can i write a text background of my treewidget using QPainter?
you must draw in QWidget:: paintEvent.
Re: How can i write a text background of my treewidget using QPainter?
void QWidget::paintEvent(QPaintEvent *)
{
QPainter p;
p.begin( tree_widget );
p.drawText( 5, 5, QString("Something"));
p.end();
}
ERROR:
The program has unexpectedly finished.
Re: How can i write a text background of my treewidget using QPainter?
cool!
if you want to draw on a tree widget you must:
-- subclass QTreeWidget/QTreeView and reimplement paintEvent;
Code:
...
{
//drawing stuff
}
...
-- install event filter on a tree widget and process QPaintEvent.
Code:
...
m_treeWidget->viewport()->installEventFilter(this);
...
{
if (o
== m_treeWidget
->viewport
() && e
->type
() == QEvent::Paint) { //draw stuff
}
}
Re: How can i write a text background of my treewidget using QPainter?
Sorry, i don`t understand .
have you got an example code about this problem?
Re: How can i write a text background of my treewidget using QPainter?
Re: How can i write a text background of my treewidget using QPainter?
thanks.. it`s worked... :):):):)
Re: How can i write a text background of my treewidget using QPainter?
how can i refresh this event filter or painter?
Now it`s working when programme started.
Re: How can i write a text background of my treewidget using QPainter?
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.