VariableChooser: Create widgets before assigning models

With Qt 5.7 the currentChanged() callback is called immediately on
QTreeView::setModel(), which leads to the label text being set. That
crashes if the label hasn't been created, yet.

Change-Id: I73763e1ac1c86215090a8f4b0118bc0cd286cf47
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Ulf Hermann
2016-03-29 18:37:50 +02:00
parent 063c8d45c8
commit af0b93196b

View File

@@ -245,9 +245,9 @@ VariableChooserPrivate::VariableChooserPrivate(VariableChooser *parent)
m_defaultDescription = VariableChooser::tr("Select a variable to insert.");
m_variableTree = new VariableTreeView(q, this);
m_variableTree->setModel(&m_model);
m_variableDescription = new QLabel(q);
m_variableTree->setModel(&m_model);
m_variableDescription->setText(m_defaultDescription);
m_variableDescription->setMinimumSize(QSize(0, 60));
m_variableDescription->setAlignment(Qt::AlignLeft|Qt::AlignTop);