QPainter::begin: Cannot paint on a null pixmap
Hi,
I have a QTreeWidget in my application. I load some values and icons into that tree. My code is here,
item = new QTreeWidgetItem(ManagerTree);
item->setExpanded( true );
item->setText( 0, "country" );
item->setIcon(0,QIcon("D:\Images\image.png"));
and it is working. But When i set the property
ManagerTree->setAnimated(true);
and make, then I didn't get any warning or errors. But when I run the program, it display some messages like this in my cunsol.
QPainter::begin: Cannot paint on a null pixmap
QPainter::setWorldTransform: Painter not active
QPainter::end: Painter not active, aborted
How can I solve it?
Please help me..............
Re: QPainter::begin: Cannot paint on a null pixmap
Which Qt release do you use?
Re: QPainter::begin: Cannot paint on a null pixmap
Hello,
I have the same problem. I have a form with an embedded QTreeWidget. I fill the tree widget with items in the form's constructor. As soon as I set the "animated" property of the QTreeWidget to true, I get the following run-time warnings:
Code:
QPainter::begin: Cannot paint on a
null pixmap
QPainter::end: Painter not active, aborted
After adding the items to QTreeWidget, I expand the top-level tree items to reveal the items they contain. If I comment out the statement expanding the items (widgetItem->setExpanded()), the warning disappears.
I'm using Qt 4.5.1 on a RedHat system.
Thanks in advance for any suggestions!
Re: QPainter::begin: Cannot paint on a null pixmap
well a possibly solution could be to set the animated option at the end of your c-tor, after you have expanded your items. The user will see nothing either because the widget is shown after the c-tor is finished.
Re: QPainter::begin: Cannot paint on a null pixmap
Lykurg,
Thanks, this works well enough. So, in the form designer I cleared the animated property of my QTreeWidget. In the form's constructor I add items to the tree, expanding header items appropriately, and once I'm done, I set the animated property to true.
It would be interesting to find out what the problem was to begin with (animation while the widget is not displayed, perhaps?).
Thanks again!
Re: QPainter::begin: Cannot paint on a null pixmap
Quote:
Originally Posted by
BadHare
Lykurg,
Thanks, this works well enough. So, in the form designer I cleared the
animated property of my
QTreeWidget. In the form's constructor I add items to the tree, expanding header items appropriately, and once I'm done, I set the
animated property to
true.
It would be interesting to find out what the problem was to begin with (animation while the widget is not displayed, perhaps?).
Thanks again!
It seems that QTreeWidget doesn't like directly altering QTreeWidgetItem's "expanded" status via QTreeWidgetItem itself when Animation is enabled.
I had to turn off the animation before doing QTreeWidgetItem::setExpanded () and then turn the animation back on after.. It worked like a charm!
(It resolves the warning issue, and still lets the user see the pleasant animation when she interacts with the TreeWidget)
The problem in my case was a little bit more serious than that of BadHare's because I expand the tree dynamically depending on other actions the user performs.. So the user will see instance of the message every time she aforementioned the aforementioned task.