1 Attachment(s)
Saving the entire .ui form as an Image file from QTcreator
Hi,
I am trying to save the entire 'MainWindow.ui' form, of my QT widget Application, as an Image (.jpg or .png) file in my system. The view/form has Mainwindow--> Central widget--> which contains multiple frame with grid layout and multiple QGraphicsView. I am trying to save the form in Qt designer from Qt creator.
My requirement is to save entire view as an image file in my system. Please tell me how do i save the entire form as an image file.
Attachment 12238
Thanks.
Qt version- 5.7
PS: PFA an image of the view.
Re: Saving the entire .ui form as an Image file from QTcreator
Quote:
My requirement is to save entire view as an image file in my system. Please tell me how do i save the entire form as an image file.
Do you need to do this once, or do you need to do it at anytime while your program is running?
If you need to do it once, then use Qt Designer's tool to view your form (sorry, I don't remember the command) and use Windows Snipping Tool or some other software to make a screen shot.
If you need to do it at any time while the program is running, then use the QWidget::render() to paint into a QPixmap, then QPixmap::save() to save it to your file.
2 Attachment(s)
Re: Saving the entire .ui form as an Image file from QTcreator
Thanks for your reply. I have to do it each time the program is running. Then distort the Image using image magick and load it again to the view.
Attachment 12240 This has to look like this one after distortion -> Attachment 12241
Below is my code for saving but i dont see it in my project folder. Please let me know what is going wrong.
Code:
widget->render(&pic);
pic.save("testScreen.png");
my widget is the container containing all the frames, graphicviews and labels.
Re: Saving the entire .ui form as an Image file from QTcreator
If you don't specify a path then the file will be written to the application's working directory.
Are you launching your application with the "project folder" as its working directory?
Cheers,
_
Re: Saving the entire .ui form as an Image file from QTcreator
Yes doing it from the directory. I gave the full path and it solved my issue.
Thanks so much! And gosh i can be dumb :P
Re: Saving the entire .ui form as an Image file from QTcreator
By the way, QPixmap::grabWidget() is an obsolete method. QWidget::render() does the same thing, and in fact in your code posted above, you're really capturing the pixmap twice - once in line 3, then again in line 4. Get rid of line 3 and your code will work in Qt5.