diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-04-15 22:10:15 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-05-19 08:43:35 +0200 |
commit | bed49e664c0ae6719e712c4750feb2b704484977 (patch) | |
tree | d0b654aa95522aa798c93183e44cbd44fa5a6bda /examples/assistant/simpletextviewer/findfiledialog.cpp | |
parent | 27f8fe5b21ac555cda9d16b2581f02a4305df1ea (diff) |
Polish the SimpleTextViewer example
- Port to Qt 5 connection syntax, fixing error in Qt 6
QObject::connect: No such signal QComboBox::currentIndexChanged(QString) in findfiledialog.cpp:194
- Remove unused functions and parameters to avoid QOverload
- Add process error handling
Change-Id: I923f44ce0eb27b7f73f9a0e16c11f48a80a0c03a
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
(cherry picked from commit 153b75db83ca4d3db26829bd85271e7fa88b402c)
Diffstat (limited to 'examples/assistant/simpletextviewer/findfiledialog.cpp')
-rw-r--r-- | examples/assistant/simpletextviewer/findfiledialog.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/examples/assistant/simpletextviewer/findfiledialog.cpp b/examples/assistant/simpletextviewer/findfiledialog.cpp index bb47ae4fd..1eab5ad7f 100644 --- a/examples/assistant/simpletextviewer/findfiledialog.cpp +++ b/examples/assistant/simpletextviewer/findfiledialog.cpp @@ -105,13 +105,11 @@ void FindFileDialog::help() } //! [2] -void FindFileDialog::openFile(QTreeWidgetItem *item) +void FindFileDialog::openFile() { - if (!item) { - item = foundFilesTree->currentItem(); - if (!item) - return; - } + auto item = foundFilesTree->currentItem(); + if (!item) + return; QString fileName = item->text(0); QString path = directoryComboBox->currentText() + QDir::separator(); @@ -161,14 +159,14 @@ void FindFileDialog::createButtons() { browseButton = new QToolButton; browseButton->setText(tr("...")); - connect(browseButton, SIGNAL(clicked()), this, SLOT(browse())); + connect(browseButton, &QAbstractButton::clicked, this, &FindFileDialog::browse); buttonBox = new QDialogButtonBox(QDialogButtonBox::Open | QDialogButtonBox::Cancel | QDialogButtonBox::Help); - connect(buttonBox, SIGNAL(accepted()), this, SLOT(openFile())); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - connect(buttonBox, SIGNAL(helpRequested()), this, SLOT(help())); + connect(buttonBox, &QDialogButtonBox::accepted, this, &FindFileDialog::openFile); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + connect(buttonBox, &QDialogButtonBox::helpRequested, this, &FindFileDialog::help); } void FindFileDialog::createComboBoxes() @@ -186,10 +184,10 @@ void FindFileDialog::createComboBoxes() directoryComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - connect(fileNameComboBox, SIGNAL(editTextChanged(QString)), - this, SLOT(update())); - connect(directoryComboBox, SIGNAL(currentIndexChanged(QString)), - this, SLOT(update())); + connect(fileNameComboBox, &QComboBox::editTextChanged, + this, &FindFileDialog::update); + connect(directoryComboBox, &QComboBox::currentTextChanged, + this, &FindFileDialog::update); } void FindFileDialog::createFilesTree() @@ -200,8 +198,8 @@ void FindFileDialog::createFilesTree() foundFilesTree->setRootIsDecorated(false); foundFilesTree->setSelectionMode(QAbstractItemView::SingleSelection); - connect(foundFilesTree, SIGNAL(itemActivated(QTreeWidgetItem*,int)), - this, SLOT(openFile(QTreeWidgetItem*))); + connect(foundFilesTree, &QTreeWidget::itemActivated, + this, &FindFileDialog::openFile); } void FindFileDialog::createLabels() |