Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-29310

QComboBox as item delegate for QTableWidget in QGraphicsView can not show popup menu or crashed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Incomplete
    • Icon: P2: Important P2: Important
    • Some future release
    • 4.8.1, 5.0.0
    • Widgets: GraphicsView
    • None
    • OpenSUSE 12.2 64 bit; Qt 4.8.1/5.0; GCC 4.7.1; Intel Core i5 2500K; Nvidia GTX 570 driver 310.19

      QComboBox can not show popup menu when it is used as item delegate of QTableWidget which is added into QGraphicsView using Qt4.8.x. And the application just crased using Qt5.0. This issue can be reproduced using codes as follow.

       
      class QComboBoxDelegate : public QItemDelegate
      {
          Q_OBJECT
      public:
          explicit QComboBoxDelegate(QWidget *parent = 0);
          QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,const QModelIndex &index) const{
              QStringList itemList;
              itemList<<"1"<<"2"<<"3"<<"4"<<"5";
              QComboBox *comboBox = new QComboBox(parent);
              comboBox->addItems(itemList);
              return comboBox;
          }
          void setEditorData(QWidget *editor, const QModelIndex &index) const{}
          void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const{}
          void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const{}
      };
      int main(int argc, char *argv[]){
          QApplication a(argc, argv);
          QGraphicsView graphicsView;
          QGraphicsScene scene;
          QTableWidget tableWidget(2,2);
          QComboBoxDelegate itemDelegate;
      
          tableWidget.setItemDelegate(&itemDelegate);
          graphicsView.setScene(&scene);
          scene.addWidget(&tableWidget);
          graphicsView.show();
          return a.exec();
      }
      

       
      And a source file with main function has been attached.

        1. main.cpp
          1 kB
          ZHAO Peng
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Unassigned Unassigned
            zhaopengqt ZHAO Peng
            Votes:
            4 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes