#include <QApplication>
#include <QWidget>
#include <QLabel>
#include <QComboBox>
#include <QVBoxLayout>
#include <QIcon>
int main(int argc,char *argv[])
{
QApplication app(argc,argv);
QWidget *window = new QWidget;
window->setWindowTitle("QComboBox");
window->resize(300,200);
QComboBox *comboBox = new QComboBox;
comboBox->setEditable(true);
comboBox->insertItem(0,QIcon( ":/up.png" ),"YANGWEI");
comboBox->insertItem(1,QIcon(":/forward"),"YANGWEI1");
QLabel *label = new QLabel("label");
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(comboBox);
layout->addWidget(label);
//为什么加上QComboBox就不好用了?
// QObject::connect(comboBox,SIGNAL(QComboBox::activated(const QString &)),label,SLOT(setText(const QString &)));
QObject::connect(comboBox,SIGNAL(activated(const QString &)),label,SLOT(setText(const QString &)));
window->setLayout(layout);
window->show();
return app.exec();
}
这里的activated不是QComboBox的吗?