Seite 1 von 1
Screenshot - zu shootendes Fenster bestimmen
Verfasst: 30. Januar 2008 18:05
von AndiLatte
Ich habe das Problem, dass wenn ich einen Screenshot per QT-Funktion habe ich als oberstes Fenster das "save as" Fenster. Wie kann ich bestimmen, dass das Fenster darunter ein sogar von einem bestimmten Fenster ein Screenshot gemacht wird....
Verfasst: 31. Januar 2008 17:19
von CaptnChaos
platform?
ich denke mal das ist wieder platformabhängig.
Verfasst: 31. Januar 2008 17:52
von solarix
Warum den via printscreen und nicht direkt via Qt-Methoden? Qt kann doch so wunderbar sich selbst rendern..
Code: Alles auswählen
QPixmap QPixmap::grabWidget ( QWidget * widget, const QRect & rectangle )
QPixmap QPixmap::grabWidget ( QWidget * widget, int x = 0, int y = 0, int width = -1, int height = -1 )
QPixmap QPixmap::grabWindow ( WId window, int x = 0, int y = 0, int width = -1, int height = -1 )
bool QPixmap::save ( const QString & fileName, const char * format = 0, int quality = -1 ) const
Verfasst: 1. Februar 2008 09:28
von AndiLatte
so soehts bei mir aus.
void MainWindow::newScreenshot(){
QTimer::singleShot(0, this, SLOT(shootScreen()));
saveScreenshot();
}
void MainWindow::shootScreen() {
originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId());
}
void MainWindow::saveScreenshot() {
QString format = "png";
QString initialPath = tr("untitled.") + format;
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"),
initialPath,
tr("%1 Files (*.%2);;All Files (*)")
.arg(format.toUpper())
.arg(format));
if (!fileName.isEmpty())
originalPixmap.save(fileName, format.toAscii());
}
ich dachte ich gehe einfach über die fenster Id ran..
danke für die tipps
Verfasst: 1. Februar 2008 10:24
von CaptnChaos
das ist ja schön, dass Qt sich selbst rendern kann. deshalb kann es aber keine externen Fenster rendern. Und eine Id von einem Fenster zu bekommen ist nunmal platformabhängig. Leuchtet das ein?
Verfasst: 1. Februar 2008 10:30
von Christian81
Ich glaube KSnapshot geht so vor
Mouse global grabben
Auf MouseKlick warten
Über QDesktopWidget das darunterliegende Fenster

D) bestimmen
per QPixmap QPixmap::grabWindow ( WId window, ...) den Screenshot anfertigen
Zumindest würde ich es so machen.