Qt-interest Archive, May 2008
saving window as picture
Message 1 in thread
Is it possible to save a QT window in JPG or PNG or any other picture formats? Does QT provide some functions and interfaces?
-------------------
Mahmood Naderan
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
Message 2 in thread
Mahmood Naderan schrieb:
> Is it possible to save a QT window in JPG or PNG or any other picture
> formats? Does QT provide some functions and interfaces?
QWidget::render(...)
Stefan
--
[ signature omitted ]
Message 3 in thread
Mahmood Naderan wrote:
> Is it possible to save a QT window in JPG or PNG or any other picture
> formats? Does QT provide some functions and interfaces?
>
> -------------------
> Mahmood Naderan
You can use http://doc.trolltech.com/4.4/qwidget.html#render
<http://doc.trolltech.com/4.4/qwidget.html#render>or, by Qt Designer
(File-> Save Image)
--
[ signature omitted ]
Message 4 in thread
>QWidget::render(...)
seems that this function is in new versions of QT. how about older ones such 3.3? http://doc.trolltech.com/4.4/qwidget.html
-------------------
Mahmood Naderan
----- Original Message ----
From: Weinzierl Stefan <Stefan@xxxxxxxxxxxxxxxxxxx>
To: qt-interest@xxxxxxxxxxxxx
Cc: QT mailing list <qt-interest@xxxxxxxxxxxxx>
Sent: Monday, May 12, 2008 2:23:01 PM
Subject: Re: saving window as picture
Mahmood Naderan schrieb:
> Is it possible to save a QT window in JPG or PNG or any other picture
> formats? Does QT provide some functions and interfaces?
QWidget::render(...)
Stefan
--
[ signature omitted ]
Message 5 in thread
> QPixmap::grabWindow(QApplication::desktop()->winId()).save("filename",
> "PNG") if you mean screenshot.
yes it takes screenshot of of whole screen.
> You can use any other widget instead of QApplication::desktop()
you mean QApplication::activeWindow () ?
> QPixmap pixmap(widget->size());
> widget->render(&pixmap);
> pixmap.save("myWidget.png");
As I said, I think this function is for v4 and newer.
-------------------
Mahmood Naderan
----- Original Message ----
From: casper <casper@xxxxxxxxxxxx>
To: Mahmood Naderan <nt_mahmood@xxxxxxxxx>
Sent: Monday, May 12, 2008 2:09:04 PM
Subject: Re: saving window as picture
casper wrote:
> QPixmap::grabWindow(QApplication::desktop()->winId()).save("filename",
> "PNG") if you mean screenshot.
> See screenshot example for details.
>
>
You can use any other widget instead of QApplication::desktop().
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
Message 6 in thread
>I mean QPixmap::grabWindow(widget->winId()).save("filename", "PNG")
>where "widget" is pointer to any other QWidget which you want to save as
>picture
Thank you. It got solved. So in short:
1) to capture the whole screen: QPixmap::grabWindow(widget->winId()).save("filename.png", "PNG");
2) to capture the active (focused) window:QPixmap::grabWindow(widget->winId()).save("filename.png", "PNG");
You forgot to append .png in the string :)
Thanks again,
-------------------
Mahmood Naderan
----- Original Message ----
From: casper <casper@xxxxxxxxxxxx>
To: Mahmood Naderan <nt_mahmood@xxxxxxxxx>
Sent: Monday, May 12, 2008 3:31:02 PM
Subject: Re: saving window as picture
Mahmood Naderan wrote:
> > QPixmap::grabWindow(QApplication::desktop()->winId()).save("filename",
> > "PNG") if you mean screenshot.
> yes it takes screenshot of of whole screen.
>
>
> > You can use any other widget instead of QApplication::desktop()
>
> you mean QApplication::activeWindow () ?
>
>
I mean QPixmap::grabWindow(widget->winId()).save("filename", "PNG")
where "widget" is pointer to any other QWidget which you want to save as
picture
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ