summaryrefslogtreecommitdiffstats
path: root/tests/manual/widgets/itemviews/delegate/example.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual/widgets/itemviews/delegate/example.cpp')
-rw-r--r--tests/manual/widgets/itemviews/delegate/example.cpp41
1 files changed, 35 insertions, 6 deletions
diff --git a/tests/manual/widgets/itemviews/delegate/example.cpp b/tests/manual/widgets/itemviews/delegate/example.cpp
index c65f49f266..dcebf437b1 100644
--- a/tests/manual/widgets/itemviews/delegate/example.cpp
+++ b/tests/manual/widgets/itemviews/delegate/example.cpp
@@ -45,6 +45,7 @@
#include <QStandardItemModel>
#include <QItemDelegate>
#include <QDebug>
+#include <QComboBox>
class ExampleEditor : public QLineEdit
{
@@ -56,13 +57,26 @@ public:
class ExampleDelegate : public QItemDelegate
{
public:
- ExampleDelegate():QItemDelegate() { m_editor = new ExampleEditor(0); }
+ ExampleDelegate() : QItemDelegate()
+ {
+ m_editor = new ExampleEditor(0);
+ m_combobox = new QComboBox(0);
+ m_combobox->addItem(QString::fromUtf8("item1"));
+ m_combobox->addItem(QString::fromUtf8("item2"));
+ }
protected:
- QWidget* createEditor(QWidget *p, const QStyleOptionViewItem &o, const QModelIndex &) const
+ QWidget* createEditor(QWidget *p, const QStyleOptionViewItem &o, const QModelIndex &i) const
{
- m_editor->setParent(p);
- m_editor->setGeometry(o.rect);
- return m_editor;
+ // doubleclick rownumber 3 (last row) to see the difference.
+ if (i.row() == 3) {
+ m_combobox->setParent(p);
+ m_combobox->setGeometry(o.rect);
+ return m_combobox;
+ } else {
+ m_editor->setParent(p);
+ m_editor->setGeometry(o.rect);
+ return m_editor;
+ }
}
void destroyEditor(QWidget *editor, const QModelIndex &) const
{
@@ -71,10 +85,25 @@ protected:
}
// Avoid setting data - and therefore show that the editor keeps its state.
- void setEditorData(QWidget*, const QModelIndex &) const { }
+ void setEditorData(QWidget* w, const QModelIndex &) const
+ {
+ QComboBox *combobox = qobject_cast<QComboBox*>(w);
+ if (combobox) {
+ qDebug() << "Try to show popup at once";
+ // Now we could try to make a call to
+ // QCoreApplication::processEvents();
+ // But it does not matter. The fix:
+ // https://codereview.qt-project.org/40608
+ // is blocking QComboBox from reacting to this doubleclick edit event
+ // and we need to do that since the mouseReleaseEvent has not yet happened,
+ // and therefore cannot be processed.
+ combobox->showPopup();
+ }
+ }
~ExampleDelegate() { delete m_editor; }
mutable ExampleEditor *m_editor;
+ mutable QComboBox *m_combobox;
};
int main(int argc, char *argv[])