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

QComboBox popup not shown when used as editor for item view embedded in graphics scene

    XMLWordPrintable

Details

    Description

      Consider the following:

      A QTableView has an item delegate which provides QComboBoxes as editors. The table view is embedded into a QGraphicsScene, but when a combo box editor is shown, its popup is never shown when the user clicks on the combo box arrow.

      Note that the problem only seems to occur when the user tries to click on the combo box arrow with the mouse. When invoking the combo box editor with keys, the combo box popup is shown as expected.

      The problem does not occur with an embedded top-level combo box, either.

      The following example demonstrates the problem:

      #include <QtGui>
      
      class Delegate : public QStyledItemDelegate
      {
          Q_OBJECT
      
      public:
          Delegate(QObject *parent = 0) : QStyledItemDelegate(parent)
          {
          }
      
          QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
          {
              QComboBox *cb = new QComboBox(parent);
              cb->addItem("foo");
              cb->addItem("bar");
              cb->addItem("foobar");
      
              return cb;
          }
      };
      
      #include "main.moc"
      
      int main(int argc, char **argv)
      {
          QApplication app(argc, argv);
      
          QTableView *table = new QTableView;
          QStandardItemModel *model = new QStandardItemModel(4, 1, table);
          Delegate *delegate = new Delegate(table);
      
          table->setModel(model);
          table->setItemDelegate(delegate);
      
          QGraphicsView view;
          QGraphicsScene *scene = new QGraphicsScene;
      
          scene->addWidget(table);
      
          view.setScene(scene);
          view.show();
      
          return app.exec();
      }
      
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            sthomass Stian Sandvik Thomassen (closed Nokia identity) (Inactive)
            Votes:
            5 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes