summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/tools/completer/mainwindow.cpp24
-rw-r--r--examples/tools/completer/mainwindow.h3
2 files changed, 23 insertions, 4 deletions
diff --git a/examples/tools/completer/mainwindow.cpp b/examples/tools/completer/mainwindow.cpp
index 8ea1c39..06f16de 100644
--- a/examples/tools/completer/mainwindow.cpp
+++ b/examples/tools/completer/mainwindow.cpp
@@ -75,6 +75,12 @@ MainWindow::MainWindow(QWidget *parent)
caseCombo->addItem(tr("Case Insensitive"));
caseCombo->addItem(tr("Case Sensitive"));
caseCombo->setCurrentIndex(0);
+
+ QLabel *maxVisibleLabel = new QLabel;
+ maxVisibleLabel->setText(tr("Max Visible Items"));
+ maxVisibleSpinBox = new QSpinBox;
+ maxVisibleSpinBox->setRange(3,25);
+ maxVisibleSpinBox->setValue(10);
//! [0]
//! [1]
@@ -90,6 +96,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(modelCombo, SIGNAL(activated(int)), this, SLOT(changeModel()));
connect(modeCombo, SIGNAL(activated(int)), this, SLOT(changeMode(int)));
connect(caseCombo, SIGNAL(activated(int)), this, SLOT(changeCase(int)));
+ connect(maxVisibleSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeMaxVisible(int)));
//! [2]
//! [3]
@@ -99,9 +106,10 @@ MainWindow::MainWindow(QWidget *parent)
layout->addWidget(modelLabel, 0, 0); layout->addWidget(modelCombo, 0, 1);
layout->addWidget(modeLabel, 1, 0); layout->addWidget(modeCombo, 1, 1);
layout->addWidget(caseLabel, 2, 0); layout->addWidget(caseCombo, 2, 1);
- layout->addWidget(wrapCheckBox, 3, 0);
- layout->addWidget(contentsLabel, 4, 0, 1, 2);
- layout->addWidget(lineEdit, 5, 0, 1, 2);
+ layout->addWidget(maxVisibleLabel, 3, 0); layout->addWidget(maxVisibleSpinBox, 3, 1);
+ layout->addWidget(wrapCheckBox, 4, 0);
+ layout->addWidget(contentsLabel, 5, 0, 1, 2);
+ layout->addWidget(lineEdit, 6, 0, 1, 2);
centralWidget->setLayout(layout);
setCentralWidget(centralWidget);
@@ -205,6 +213,7 @@ void MainWindow::changeModel()
{
delete completer;
completer = new QCompleter(this);
+ completer->setMaxVisibleItems(maxVisibleSpinBox->value());
switch (modelCombo->currentIndex()) {
default:
@@ -256,9 +265,16 @@ void MainWindow::changeModel()
//! [14]
//! [15]
+void MainWindow::changeMaxVisible(int max)
+{
+ completer->setMaxVisibleItems(max);
+}
+//! [15]
+
+//! [16]
void MainWindow::about()
{
QMessageBox::about(this, tr("About"), tr("This example demonstrates the "
"different features of the QCompleter class."));
}
-//! [15]
+//! [16]
diff --git a/examples/tools/completer/mainwindow.h b/examples/tools/completer/mainwindow.h
index f6c962b..30b8d26 100644
--- a/examples/tools/completer/mainwindow.h
+++ b/examples/tools/completer/mainwindow.h
@@ -52,6 +52,7 @@ class QLabel;
class QLineEdit;
class QProgressBar;
class QCheckBox;
+class QSpinBox;
QT_END_NAMESPACE
//! [0]
@@ -67,6 +68,7 @@ private slots:
void changeCase(int);
void changeMode(int);
void changeModel();
+ void changeMaxVisible(int);
//! [0]
//! [1]
@@ -77,6 +79,7 @@ private:
QComboBox *caseCombo;
QComboBox *modeCombo;
QComboBox *modelCombo;
+ QSpinBox *maxVisibleSpinBox;
QCheckBox *wrapCheckBox;
QCompleter *completer;
QLabel *contentsLabel;