本文整理汇总了C++中QAbstractItemModel::setParent方法的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractItemModel::setParent方法的具体用法?C++ QAbstractItemModel::setParent怎么用?C++ QAbstractItemModel::setParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAbstractItemModel
的用法示例。
在下文中一共展示了QAbstractItemModel::setParent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWidget
ColorDialogPanel::ColorDialogPanel(QWidget *parent)
: QWidget(parent)
, m_colorComboBox(new QComboBox)
, m_showAlphaChannel(new QCheckBox(tr("Show alpha channel")))
, m_noButtons(new QCheckBox(tr("Don't display OK/Cancel buttons")))
, m_dontUseNativeDialog(new QCheckBox(tr("Don't use native dialog")))
{
// Options
QGroupBox *optionsGroupBox = new QGroupBox(tr("Options"), this);
QVBoxLayout *optionsLayout = new QVBoxLayout(optionsGroupBox);
optionsLayout->addWidget(m_showAlphaChannel);
optionsLayout->addWidget(m_noButtons);
optionsLayout->addWidget(m_dontUseNativeDialog);
// Color
QGroupBox *colorGroupBox = new QGroupBox(tr("Color"), this);
QVBoxLayout *colorLayout = new QVBoxLayout(colorGroupBox);
colorLayout->addWidget(m_colorComboBox);
m_colorComboBox->addItems(svgColorNames());
m_colorComboBox->setEditable(true);
QAbstractItemModel *sourceModel = m_colorComboBox->model();
ColorProxyModel* proxyModel = new ColorProxyModel(m_colorComboBox);
proxyModel->setSourceModel(sourceModel);
sourceModel->setParent(proxyModel);
m_colorComboBox->setModel(proxyModel);
// Buttons
QGroupBox *buttonsGroupBox = new QGroupBox(tr("Show"));
QVBoxLayout *buttonsLayout = new QVBoxLayout(buttonsGroupBox);
addButton(tr("Exec modal"), buttonsLayout, this, SLOT(execModal()));
addButton(tr("Show modal"), buttonsLayout, this, SLOT(showModal()));
m_deleteModalDialogButton =
addButton(tr("Delete modal"), buttonsLayout, this, SLOT(deleteModalDialog()));
addButton(tr("Show non-modal"), buttonsLayout, this, SLOT(showNonModal()));
m_deleteNonModalDialogButton =
addButton(tr("Delete non-modal"), buttonsLayout, this, SLOT(deleteNonModalDialog()));
addButton(tr("Restore defaults"), buttonsLayout, this, SLOT(restoreDefaults()));
buttonsLayout->addStretch();
// Main layout
QHBoxLayout *mainLayout = new QHBoxLayout(this);
QVBoxLayout *leftLayout = new QVBoxLayout;
leftLayout->addWidget(optionsGroupBox);
leftLayout->addWidget(colorGroupBox);
leftLayout->addStretch();
mainLayout->addLayout(leftLayout);
mainLayout->addWidget(buttonsGroupBox);
enableDeleteModalDialogButton();
enableDeleteNonModalDialogButton();
restoreDefaults();
}