diff options
| author | Cristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2021-01-04 21:03:22 +0100 |
|---|---|---|
| committer | Cristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2021-01-06 14:51:48 +0100 |
| commit | d9f344fcef6bec04a787f9ea9f4ea94f15eaa26c (patch) | |
| tree | 212261cffc6086e77a9731f3e23e8d12e6715b5e /sources/pyside6/doc/codesnippets/examples | |
| parent | b6d1b76b46d7b756f7cb01361037e1cb5efc990a (diff) | |
sources: migration from format() to f-strings
This should be the last patch related the usage of f-strings
from the 'sources' directory.
Pick-to: 6.0
Change-Id: I0288d720dc4930dee088ca3396a66d1b3ba18f76
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside6/doc/codesnippets/examples')
3 files changed, 7 insertions, 6 deletions
diff --git a/sources/pyside6/doc/codesnippets/examples/dialogs/standarddialogs/dialog.cpp b/sources/pyside6/doc/codesnippets/examples/dialogs/standarddialogs/dialog.cpp index db11e22f8..3132bec55 100644 --- a/sources/pyside6/doc/codesnippets/examples/dialogs/standarddialogs/dialog.cpp +++ b/sources/pyside6/doc/codesnippets/examples/dialogs/standarddialogs/dialog.cpp @@ -52,14 +52,14 @@ i, ok = QInputDialog().getInteger(self, "QInputDialog().getInteger()", "Percentage:", 25, 0, 100, 1) if ok: - self.integerLabel.setText("{}%".format(i)) + self.integerLabel.setText(f"{i}%") //! [0] //! [1] d, ok = QInputDialog().getDouble(self, "QInputDialog().getDouble()", "Amount:", 37.56, -10000, 10000, 2) if ok: - doubleLabel.setText("${}".format()) + doubleLabel.setText(f"${d}") //! [1] //! [2] diff --git a/sources/pyside6/doc/codesnippets/examples/mainwindows/application/mainwindow.py b/sources/pyside6/doc/codesnippets/examples/mainwindows/application/mainwindow.py index f9a93cfc8..fb58f05a8 100644 --- a/sources/pyside6/doc/codesnippets/examples/mainwindows/application/mainwindow.py +++ b/sources/pyside6/doc/codesnippets/examples/mainwindows/application/mainwindow.py @@ -281,7 +281,7 @@ def writeSettings(self): //! [40] def maybeSave(self): //! [40] //! [41] - if textEdit.document()->isModified(): + if textEdit.document().isModified(): ret = QMessageBox.warning(self, tr("Application"), tr("The document has been modified.\n" "Do you want to save your changes?"), @@ -299,7 +299,7 @@ def loadFile(self, fileName): file = QFile(fileName) if !file.open(QFile.ReadOnly | QFile.Text): QMessageBox.warning(self, tr("Application"), tr("Cannot read file " - "{}:\n{}.".format(fileName, file.errorString()))) + f"{fileName}:\n{file.errorString()}.")) return in = QTextStream(file) diff --git a/sources/pyside6/doc/codesnippets/examples/mainwindows/mdi/mainwindow.py b/sources/pyside6/doc/codesnippets/examples/mainwindows/mdi/mainwindow.py index 9d0572d9a..984210189 100644 --- a/sources/pyside6/doc/codesnippets/examples/mainwindows/mdi/mainwindow.py +++ b/sources/pyside6/doc/codesnippets/examples/mainwindows/mdi/mainwindow.py @@ -163,10 +163,11 @@ class QMdiSubWindow(QMainWindow): child = windows.at(i).widget() text = "" + child_file = child.userFriendlyCurrentFile() if i < 9: - text = "{} {}".format(i + 1, child.userFriendlyCurrentFile()) + text = f"&{i + 1} {child_file}" else: - text = "{} {}".format(i + 1, child.userFriendlyCurrentFile()) + text = f"{i + 1} {child_file}" action = windowMenu.addAction(text) action.setCheckable(True) |
