QComboBox *comboBox = new QComboBox;
comboBox->addItem("Item 1");
comboBox->addItem("Item 2");
comboBox->addItem("Item 3");
// 连接信号和槽
QObject::connect(comboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
[=](int index)
qDebug() << "Selected item index: " << index;
});
分类: 控件
0 条评论