Welcome

首页 / 软件开发 / C++ / Qt Project源码结构分析

Qt Project源码结构分析2013-11-04在网上阅读了QT入门教程系列文章,感谢豆豆博客的版主,把这么好的教程和大家分享,本文是对入门教程的笔记,以期抛砖引玉,听到大家的好见解。 希望大家更好更快的学习QT,达到自己的目标,实现自己的理想。

本文分析QT项目的结构,如头文件中代码的结构与功效,主源代码文件的结构与功效。也就是说头文件中应该放些什么,源代码文件中放些什么。

先看一个经典的例子,头文件:

#ifndef FINDDIALOG_H #define FINDDIALOG_H#include <QtGui/QDialog>class QCheckBox; class QLabel; class QLineEdit; class QPushButton;class FindDialog : public QDialog { Q_OBJECTpublic: FindDialog(QWidget *parent = 0); ~FindDialog(); signals: void findNext(const QString &str, Qt::CaseSensitivity cs); void findPrevious(const QString &str, Qt::CaseSensitivity cs); private slots: void findClicked(); void enableFindButton(const QString &text); private: QLabel *label; QLineEdit *lineEdit; QCheckBox *caseCheckBox; QCheckBox *backwardCheckBox; QPushButton *findButton; QPushButton *closeButton; };#endif // FINDDIALOG_H
主函数:

#include <QApplication>#include "finddialog.h"int main(int argc, char *argv[]) { QApplication app(argc, argv); FindDialog *dialog = new FindDialog; dialog->show(); return app.exec(); }