9#define setWordCount(x) isVisible()
13 return QApplication::translate(text, text);
42 findDialog =
new FindDialog(
this);
43 connect(findDialog, &FindDialog::findNext,
44 this, &EditorWindow::findNext);
49 findDialog->activateWindow();
62#if QT_DEPRECATED_SINCE(6
, 2
)
65 QMessageBox::information(
this,
"Application name",
66 "Unable to find the user preferences file.\n"
67 "The factory default will be used instead.");
70 if (QFile::exists(filename) &&
71 QMessageBox::question(
73 tr(
"Overwrite File? -- Application Name"),
74 tr(
"A file called %1 already exists."
75 "Do you want to overwrite it?")
77 tr(
"&Yes"), tr(
"&No"),
81 switch(QMessageBox::warning(
this,
"Application name",
82 "Could not connect to the <mumble> server.\n"
83 "This program can't function correctly "
84 "without the server.\n\n",
95 switch(QMessageBox::information(
this,
"Application name here",
96 "The document contains unsaved changes\n"
97 "Do you want to save the changes before exiting?",
98 "&Save",
"&Discard",
"Cancel",
112 switch(QMessageBox::warning(
this,
"Application name here",
113 "Could not save the user preferences,\n"
114 "because the disk is full. You can delete\n"
115 "some files and press Retry, or you can\n"
116 "abort the Save Preferences operation.",
117 QMessageBox::Retry | QMessageBox::Default,
118 QMessageBox::Abort | QMessageBox::Escape)) {
119 case QMessageBox::Retry:
122 case QMessageBox::Abort:
127 QString errorDetails;
128 QMessageBox::critical(0,
"Application name here",
129 QString(
"An internal error occurred. Please ") +
130 "call technical support at 1234-56789 and report\n"+
131 "these numbers:\n\n" + errorDetails +
132 "\n\nApplication will now exit.");
134 QMessageBox::about(
this,
"About <Application>",
135 "<Application> is a <one-paragraph blurb>\n\n"
136 "Copyright 1991-2003 Such-and-such. "
137 "<License words here.>\n\n"
138 "For technical support, call 1234-56789 or see\n"
139 "http://www.such-and-such.com/Application/\n");
143 QMessageBox mb(
"Application name here",
144 "Saving the file will overwrite the original file on the disk.\n"
145 "Do you really want to save?",
146 QMessageBox::Information,
147 QMessageBox::Yes | QMessageBox::Default,
149 QMessageBox::Cancel | QMessageBox::Escape);
150 mb.setButtonText(QMessageBox::Yes,
"Save");
151 mb.setButtonText(QMessageBox::No,
"Discard");
153 case QMessageBox::Yes:
156 case QMessageBox::No:
159 case QMessageBox::Cancel:
168 QMessageBox mb(
"Application Name",
169 "Hardware failure.\n\nDisk error detected\nDo you want to stop?",
170 QMessageBox::Question,
171 QMessageBox::Yes | QMessageBox::Default,
172 QMessageBox::No | QMessageBox::Escape,
173 QMessageBox::NoButton);
174 if (mb.exec() == QMessageBox::No) {
186 QProgressDialog progress(
"Copying files...",
"Abort Copy", 0, numFiles,
this);
187 progress.setWindowModality(Qt::WindowModal);
189 for (
int i = 0; i < numFiles; i++) {
190 progress.setValue(i);
192 if (progress.wasCanceled())
196 progress.setValue(numFiles);
219 pd =
new QProgressDialog(
"Operation in progress.",
"Cancel", 0, 100);
220 connect(pd, &QProgressDialog::canceled,
this, &Operation::cancel);
221 t =
new QTimer(
this);
222 connect(t, &QTimer::timeout,
this, &Operation::perform);
232 if (steps > pd->maximum())
246 using ExtendedControls = QWidget;
247 QPushButton *findButton;
248 QPushButton *moreButton;
250 QVBoxLayout *mainLayout;
253 mainLayout->setSizeConstraint(QLayout::SetFixedSize);
255 findButton =
new QPushButton(tr(
"&Find"));
256 moreButton =
new QPushButton(tr(
"&More..."));
257 moreButton->setCheckable(
true);
259 extension =
new ExtendedControls;
260 mainLayout->addWidget(extension);
263 connect(moreButton, &QAbstractButton::toggled, extension, &QWidget::setVisible);
267 QDialogButtonBox *buttonBox =
new QDialogButtonBox(Qt::Vertical);
268 buttonBox->addButton(findButton, QDialogButtonBox::ActionRole);
269 buttonBox->addButton(moreButton, QDialogButtonBox::ActionRole);
Operation(QObject *parent)
[4]
void perform()
[4] //! [5]