diff options
author | Tatiana Borisova <[email protected]> | 2024-12-05 17:44:55 +0100 |
---|---|---|
committer | Tatiana Borisova <[email protected]> | 2025-01-02 15:01:45 +0100 |
commit | 5525779b2ea9e2805c5d4a1b6b070ca8b4838396 (patch) | |
tree | 10d10a5421533396a46f388b7509431350c10152 | |
parent | 343cc50c224655ba8da5cc02d263a9b70f10d529 (diff) |
QTextStream: use new operator bool() around the code
- After adding the QTextStream::operator bool(), it is not required to
check the QTextStream::status(). It is enough to use the reference
of stream in the statement, which returns true if stream status is OK.
New operator usage makes code more convenient.
Task-number: QTBUG-52189
Change-Id: Id9ecaa8a5c9cf1931dbeefa85f9d948d15379a82
Reviewed-by: Marc Mutz <[email protected]>
-rw-r--r-- | src/gui/image/qxpmhandler.cpp | 2 | ||||
-rw-r--r-- | tests/manual/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp | 5 |
2 files changed, 3 insertions, 4 deletions
diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index be024d752dc..8f39d281e72 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -1137,7 +1137,7 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const s << '\"'; } s << "};" << Qt::endl; - return (s.status() == QTextStream::Ok); + return static_cast<bool>(s); } QXpmHandler::QXpmHandler() diff --git a/tests/manual/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp b/tests/manual/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp index a883e7c58af..f6fd06e96fb 100644 --- a/tests/manual/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp +++ b/tests/manual/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp @@ -21,9 +21,8 @@ DragWidget::DragWidget(QWidget *parent) int x = 5; int y = 5; - while (!inputStream.atEnd()) { - QString word; - inputStream >> word; + QString word; + while (inputStream >> word) { if (!word.isEmpty()) { DragLabel *wordLabel = new DragLabel(word, this); wordLabel->move(x, y); |