examples/tools/treemodelcompleter/mainwindow.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
    50     createMenu();
    50     createMenu();
    51 
    51 
    52     completer = new TreeModelCompleter(this);
    52     completer = new TreeModelCompleter(this);
    53     completer->setModel(modelFromFile(":/resources/treemodel.txt"));
    53     completer->setModel(modelFromFile(":/resources/treemodel.txt"));
    54     completer->setSeparator(QLatin1String("."));
    54     completer->setSeparator(QLatin1String("."));
    55     QObject::connect(completer, SIGNAL(highlighted(const QModelIndex&)),
    55     QObject::connect(completer, SIGNAL(highlighted(QModelIndex)),
    56                      this, SLOT(highlight(const QModelIndex&)));
    56                      this, SLOT(highlight(QModelIndex)));
    57 
    57 
    58     QWidget *centralWidget = new QWidget;
    58     QWidget *centralWidget = new QWidget;
    59 
    59 
    60     QLabel *modelLabel = new QLabel;
    60     QLabel *modelLabel = new QLabel;
    61     modelLabel->setText(tr("Tree Model<br>(Double click items to edit)"));
    61     modelLabel->setText(tr("Tree Model<br>(Double click items to edit)"));
    80     QLabel *separatorLabel = new QLabel;
    80     QLabel *separatorLabel = new QLabel;
    81     separatorLabel->setText(tr("Tree Separator"));
    81     separatorLabel->setText(tr("Tree Separator"));
    82 
    82 
    83     QLineEdit *separatorLineEdit = new QLineEdit;
    83     QLineEdit *separatorLineEdit = new QLineEdit;
    84     separatorLineEdit->setText(completer->separator());
    84     separatorLineEdit->setText(completer->separator());
    85     connect(separatorLineEdit, SIGNAL(textChanged(const QString&)),
    85     connect(separatorLineEdit, SIGNAL(textChanged(QString)),
    86             completer, SLOT(setSeparator(const QString&)));
    86             completer, SLOT(setSeparator(QString)));
    87 
    87 
    88     QCheckBox *wrapCheckBox = new QCheckBox;
    88     QCheckBox *wrapCheckBox = new QCheckBox;
    89     wrapCheckBox->setText(tr("Wrap around completions"));
    89     wrapCheckBox->setText(tr("Wrap around completions"));
    90     wrapCheckBox->setChecked(completer->wrapAround());
    90     wrapCheckBox->setChecked(completer->wrapAround());
    91     connect(wrapCheckBox, SIGNAL(clicked(bool)), completer, SLOT(setWrapAround(bool)));
    91     connect(wrapCheckBox, SIGNAL(clicked(bool)), completer, SLOT(setWrapAround(bool)));
    92 
    92 
    93     contentsLabel = new QLabel;
    93     contentsLabel = new QLabel;
    94     contentsLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    94     contentsLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    95     connect(separatorLineEdit, SIGNAL(textChanged(const QString&)),
    95     connect(separatorLineEdit, SIGNAL(textChanged(QString)),
    96             this, SLOT(updateContentsLabel(const QString&)));
    96             this, SLOT(updateContentsLabel(QString)));
    97 
    97 
    98     treeView = new QTreeView;
    98     treeView = new QTreeView;
    99     treeView->setModel(completer->model());
    99     treeView->setModel(completer->model());
   100     treeView->header()->hide();
   100     treeView->header()->hide();
   101     treeView->expandAll();
   101     treeView->expandAll();