View Full Version : Saving the widget class as a QPixmap
zgulser
30th January 2009, 18:04
Hi,
I have a class foo in which I created two QGraphicsLineItem and one QGraphicsEllipseItem. Together they form a different composite shape in foo. What I want to do is saving this shape as a QPixmap! OR transfering this whole shape into a QPixmap. Is it possible it QT?
Regards
wysota
30th January 2009, 20:22
QGraphicsScene::render()
zgulser
30th January 2009, 20:23
Hi again,
Is there any idea?
Regards
zgulser
30th January 2009, 20:40
Hi,
I don't want to render. I guess I mistold my problem.
I want to convert my class, which I draw s shape in it, into a QPixmap OR,
to put my shape into a QPixmap.
Is that what you understood?
Regards
zgulser
30th January 2009, 20:45
Oh sorry, I just understood what did you say.
Hımm does it work for QPainter painter(&QPixmap_object) ?
OR grabWidget could do the same thing?
Regards
wysota
30th January 2009, 21:32
Oh boy... is it so hard to read 2-3 paragraphs of the documentation?
QPixmap myPixmap(600,400);
myPixmap.fill(Qt::white); // unless you want transparent background
QPainter p(&myPixmap);
myScene->render(&p);
p.end();
zgulser
30th January 2009, 21:42
Hi,
Yes yes, I sad I'am sorry, I didn't recognize what's written there for a moment cuz I'am really overloaded. Sorry again.
One more; scene.render(&p) makes the scene a QPixmap? cuz, it's return type is void.
By the way, what do you say about grabWidget?
Regards
wysota
30th January 2009, 23:42
One more; scene.render(&p) makes the scene a QPixmap? cuz, it's return type is void.
Think why it takes a pointer to the painter object and what it might do with it.
By the way, what do you say about grabWidget?
I say it is not for you because it would contain not only the contents of the view but also the frame of the view. Please use QScene::render() as suggested.
zgulser
2nd February 2009, 08:48
Hi,
I converted my widget to QPixmap by following the instructions that you provided, but now the widget did not fit with the QPixmap. I mean only some part of the widget can be seen on the pixmap.
Regards
wysota
2nd February 2009, 09:02
So make the pixmap bigger.
zgulser
2nd February 2009, 09:10
Yes, I did and it works OK.
I checked but didn't find how to put my widget at the middle of the pixmap. I mean I want to control the coordinates of my pixmap. By biggering the pixmap, I couldn't get the true sense of such controling since the most of the pixmap field is empty.
Thanks again wysota
Regards
wysota
2nd February 2009, 09:48
Have you tried actually reading the documentation of classes and methods before using them? Have you seen the docs of QGraphicsScene::render()?
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.