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 <marc.mutz@qt.io>
This commit is contained in:
Tatiana Borisova 2024-12-05 17:44:55 +01:00
parent 343cc50c22
commit 5525779b2e
2 changed files with 3 additions and 4 deletions

View File

@ -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()

View File

@ -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);