MainWindow 类定义 ¶
MainWindow类是子类化的QMainWindowand implements five custom slots:about(),changeCase(),changeMode(),highlight(),和updateContentsLabel().class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = nullptr); private slots: void about(); void changeCase(int); void changeMode(int); void highlight(const QModelIndex &index); void updateContentsLabel(const QString &sep);In addition, the class has two private functions,
createMenu()andmodelFromFile(), as well as private instances ofQTreeView,QComboBox,QLabel,TreeModelCompleterandQLineEdit.private: void createMenu(); QAbstractItemModel *modelFromFile(const QString &fileName); QTreeView *treeView = nullptr; QComboBox *caseCombo = nullptr; QComboBox *modeCombo = nullptr; QLabel *contentsLabel = nullptr; TreeModelCompleter *completer = nullptr; QLineEdit *lineEdit = nullptr; };