First let the user select a filename.
/******************************************************************************
saveImage
Opens a dialog where the user can select a path and filename where to save
the screen image.
On entry, we stop the timer to hold the actual screen.
On exit, we start the timer again.
******************************************************************************/
void MainWindow::saveImage()
{
refreshTimer->stop();
"untitled.png", tr("Images (*.png)"));
// you may forget this:
if (fileName != "")
ui.scopeWindow->saveImage(fileName);
// and insert the following code her
refreshTimer->start();
}
/******************************************************************************
saveImage
Opens a dialog where the user can select a path and filename where to save
the screen image.
On entry, we stop the timer to hold the actual screen.
On exit, we start the timer again.
******************************************************************************/
void MainWindow::saveImage()
{
refreshTimer->stop();
QString fileName =
QFileDialog::getSaveFileName(this, tr("Save Image"),
"untitled.png", tr("Images (*.png)"));
// you may forget this:
if (fileName != "")
ui.scopeWindow->saveImage(fileName);
// and insert the following code her
refreshTimer->start();
}
To copy to clipboard, switch view to plain text mode
In this piece of code I'm saving an image, so skip that part and the timer-parts. Only use the getting the filename.
Then save something to a textfile:
if (data.
open(QFile::WriteOnly |
QFile::Truncate)) { out << "some_text";
}
QFile data(fileName);
if (data.open(QFile::WriteOnly | QFile::Truncate)) {
QTextStream out(&data);
out << "some_text";
}
To copy to clipboard, switch view to plain text mode
Bookmarks