summaryrefslogtreecommitdiffstats
path: root/examples/widgets
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@qt.io>2022-04-07 15:21:56 +0300
committerTarja Sundqvist <tarja.sundqvist@qt.io>2022-04-07 15:21:56 +0300
commite89a6f03c4d24f18db36a906a7320035388504ba (patch)
tree47f7edb9faa26f6f4e2d3f2eea12133933d86e45 /examples/widgets
parentc8989ca20fa5798f7853f07df6e150cc407c64a4 (diff)
parent69b8ab23c93785dc69ae43ea04d5620656a4af44 (diff)
Merge remote-tracking branch 'origin/tqtc/lts-5.15.4' into tqtc/lts-5.15-opensource
Diffstat (limited to 'examples/widgets')
-rw-r--r--examples/widgets/itemviews/editabletreemodel/mainwindow.cpp2
-rw-r--r--examples/widgets/itemviews/editabletreemodel/treemodel.cpp3
-rw-r--r--examples/widgets/widgets/imageviewer/imageviewer.cpp7
-rw-r--r--examples/widgets/widgets/imageviewer/main.cpp2
4 files changed, 9 insertions, 5 deletions
diff --git a/examples/widgets/itemviews/editabletreemodel/mainwindow.cpp b/examples/widgets/itemviews/editabletreemodel/mainwindow.cpp
index 7faa325469..47fc232751 100644
--- a/examples/widgets/itemviews/editabletreemodel/mainwindow.cpp
+++ b/examples/widgets/itemviews/editabletreemodel/mainwindow.cpp
@@ -62,7 +62,7 @@ MainWindow::MainWindow(QWidget *parent)
QFile file(":/default.txt");
file.open(QIODevice::ReadOnly);
- TreeModel *model = new TreeModel(headers, file.readAll());
+ TreeModel *model = new TreeModel(headers, file.readAll(), this);
file.close();
view->setModel(model);
diff --git a/examples/widgets/itemviews/editabletreemodel/treemodel.cpp b/examples/widgets/itemviews/editabletreemodel/treemodel.cpp
index 9678e45be7..960ce7c1ca 100644
--- a/examples/widgets/itemviews/editabletreemodel/treemodel.cpp
+++ b/examples/widgets/itemviews/editabletreemodel/treemodel.cpp
@@ -212,6 +212,9 @@ bool TreeModel::removeRows(int position, int rows, const QModelIndex &parent)
//! [8]
int TreeModel::rowCount(const QModelIndex &parent) const
{
+ if (parent.isValid() && parent.column() > 0)
+ return 0;
+
const TreeItem *parentItem = getItem(parent);
return parentItem ? parentItem->childCount() : 0;
diff --git a/examples/widgets/widgets/imageviewer/imageviewer.cpp b/examples/widgets/widgets/imageviewer/imageviewer.cpp
index 7de0c7c45b..bce74a2434 100644
--- a/examples/widgets/widgets/imageviewer/imageviewer.cpp
+++ b/examples/widgets/widgets/imageviewer/imageviewer.cpp
@@ -176,6 +176,7 @@ static void initializeImageFileDialog(QFileDialog &dialog, QFileDialog::AcceptMo
mimeTypeFilters.sort();
dialog.setMimeTypeFilters(mimeTypeFilters);
dialog.selectMimeTypeFilter("image/jpeg");
+ dialog.setAcceptMode(acceptMode);
if (acceptMode == QFileDialog::AcceptSave)
dialog.setDefaultSuffix("jpg");
}
@@ -185,7 +186,7 @@ void ImageViewer::open()
QFileDialog dialog(this, tr("Open File"));
initializeImageFileDialog(dialog, QFileDialog::AcceptOpen);
- while (dialog.exec() == QDialog::Accepted && !loadFile(dialog.selectedFiles().first())) {}
+ while (dialog.exec() == QDialog::Accepted && !loadFile(dialog.selectedFiles().constFirst())) {}
}
//! [1]
@@ -194,7 +195,7 @@ void ImageViewer::saveAs()
QFileDialog dialog(this, tr("Save File As"));
initializeImageFileDialog(dialog, QFileDialog::AcceptSave);
- while (dialog.exec() == QDialog::Accepted && !saveFile(dialog.selectedFiles().first())) {}
+ while (dialog.exec() == QDialog::Accepted && !saveFile(dialog.selectedFiles().constFirst())) {}
}
//! [5]
@@ -365,7 +366,7 @@ void ImageViewer::createActions()
QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
helpMenu->addAction(tr("&About"), this, &ImageViewer::about);
- helpMenu->addAction(tr("About &Qt"), &QApplication::aboutQt);
+ helpMenu->addAction(tr("About &Qt"), this, &QApplication::aboutQt);
}
//! [18]
diff --git a/examples/widgets/widgets/imageviewer/main.cpp b/examples/widgets/widgets/imageviewer/main.cpp
index 035c769693..fbfaecde45 100644
--- a/examples/widgets/widgets/imageviewer/main.cpp
+++ b/examples/widgets/widgets/imageviewer/main.cpp
@@ -63,7 +63,7 @@ int main(int argc, char *argv[])
commandLineParser.process(QCoreApplication::arguments());
ImageViewer imageViewer;
if (!commandLineParser.positionalArguments().isEmpty()
- && !imageViewer.loadFile(commandLineParser.positionalArguments().front())) {
+ && !imageViewer.loadFile(commandLineParser.positionalArguments().constFirst())) {
return -1;
}
imageViewer.show();