在Qt4.6中把窗口部件类大体分为4类,基本窗口部件、高级窗口部件、组织用窗口部件、抽象的窗口部件。 基本窗口部件 QComboBox 基本介绍: 常用接口: 联系程序: combobox.h #ifndef COMBOBOX_H #define COMBOBOX_H #include <QtGui> class myComboBox : public QComboBox { Q_OBJECT public: myComboBox(QComboBox *parent = 0); public slots: void showCount(); }; #endif // COMBOBOX_H combobox.cpp #include "combobox.h" myComboBox::myComboBox(QComboBox *parent) :QComboBox(parent) { for (int i = 0; i < 10; ++i) { this->insertItem(i, QObject::tr("Qt %1").arg(i)); } connect(this, SIGNAL(activated(int)), this, SLOT(showCount())); } void myComboBox::showCount() { qDebug() << this->currentIndex(); } main.cpp #include "combobox.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); myComboBox *combobox = new myComboBox; qDebug() << combobox->count(); combobox->addItem("qt 11"); qDebug() << combobox->count(); combobox->show(); return app.exec(); } 高级窗口部件 组织用窗口部件 抽象的窗口部件