2010-06-04 133 views
1

可以为您爱好者能告诉我这种情况的解决方案,什么是这个代码错误

我有一个列表视图,当我对任何项目挖掘,应该会出现一个弹出列表,基于对后从弹出列表中选择的项目我将更新我的用户界面。

我已经编写了一个代码,以便在从我的视图中点击任何项目后获得弹出列表。

我的问题是一旦我点击任何项目,将得到一个弹出列表,我也将能够从弹出列表中选择项目。有一次,我在弹出列表中按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); 


    } 

回答

2

我找到了答案, 我需要从我的上述源代码中删除此行

QString item = inputdialog.getItem(this,  tr("QInputDialog::getItem()"),tr("Season:"), items, 0, false, &ok); 
+0

干得好!你可能会收集*自学者*徽章。) – mosg 2010-06-04 13:28:06

+0

@ Shadow,没有什么比你自己的调试教会你更多。:) – liaK 2010-06-04 19:26:09