diff options
Diffstat (limited to 'examples/tools/completer')
-rw-r--r-- | examples/tools/completer/completer.pro | 2 | ||||
-rw-r--r-- | examples/tools/completer/mainwindow.cpp | 24 | ||||
-rw-r--r-- | examples/tools/completer/mainwindow.h | 3 | ||||
-rw-r--r-- | examples/tools/completer/resources/wordlist.txt | 1 |
4 files changed, 25 insertions, 5 deletions
diff --git a/examples/tools/completer/completer.pro b/examples/tools/completer/completer.pro index 4ac5084..96d3734 100644 --- a/examples/tools/completer/completer.pro +++ b/examples/tools/completer/completer.pro @@ -10,3 +10,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tools/completer sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS completer.pro resources sources.path = $$[QT_INSTALL_EXAMPLES]/tools/completer INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tools/completer/mainwindow.cpp b/examples/tools/completer/mainwindow.cpp index ff7e1a1..923e806 100644 --- a/examples/tools/completer/mainwindow.cpp +++ b/examples/tools/completer/mainwindow.cpp @@ -78,6 +78,12 @@ MainWindow::MainWindow(QWidget *parent) //! [0] //! [1] + QLabel *maxVisibleLabel = new QLabel; + maxVisibleLabel->setText(tr("Max Visible Items")); + maxVisibleSpinBox = new QSpinBox; + maxVisibleSpinBox->setRange(3,25); + maxVisibleSpinBox->setValue(10); + wrapCheckBox = new QCheckBox; wrapCheckBox->setText(tr("Wrap around completions")); wrapCheckBox->setChecked(true); @@ -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 1d22a09..fb306b4 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; diff --git a/examples/tools/completer/resources/wordlist.txt b/examples/tools/completer/resources/wordlist.txt index e598a19..1f56e36 100644 --- a/examples/tools/completer/resources/wordlist.txt +++ b/examples/tools/completer/resources/wordlist.txt @@ -1366,7 +1366,6 @@ transparency transparent travel traveled -Trolltech true try turn |