你能告诉我解决这个问题的方法吗?
我有一个列表视图,当我点击任何项目时,都会出现一个弹出列表,然后根据从弹出列表中选择的项目更新我的用户界面。
我已经编写了一个代码,在点击了我视图中的任何项目之后,就可以得到弹出列表。
我的问题是,一旦我点击任何项目,将得到一个弹出列表,我也将能够从弹出列表中选择项目。一旦我在弹出列表中按OK键,我也会用组合框显示一个列表,我不知道出了什么问题。
这是我获得弹出列表的代码,请在我出错的地方帮助我
void myPopupWindow::Popupdialog()
{
QInputDialog inputdialog;
QStringList items;
items << tr("Spring") << tr("Summer");
// bool val = QObject::connect(inputdialog,SIGNAL(textValueChanged(const QString &text)),this,SLOT(selText( const QString & text )));
bool val = QObject::connect(&inputdialog,SIGNAL(textValueChanged(const QString &)),this,SLOT(selText(const QString &)));
bool ok;
inputdialog.setOptions(QInputDialog::UseListViewForComboBoxItems);
inputdialog.setComboBoxItems(items);
inputdialog.exec();
QString item = inputdialog.getItem(this, tr("QInputDialog::getItem()"),tr("Season:"), items, 0, false, &ok);
}