本文整理汇总了C++中TreeModel::setXML方法的典型用法代码示例。如果您正苦于以下问题:C++ TreeModel::setXML方法的具体用法?C++ TreeModel::setXML怎么用?C++ TreeModel::setXML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeModel
的用法示例。
在下文中一共展示了TreeModel::setXML方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWidget
MainWindow::MainWindow(QWidget *parent)
: QWidget(parent)
, m_height(30)
, m_shadowSize(5)
, m_menu(NULL)
{
this->setWindowFlags(Qt::FramelessWindowHint | Qt::Window);
this->setAttribute(Qt::WA_TranslucentBackground);
this->setWindowIcon(QIcon("./Resources/Images/icon.png"));
m_comboBox = new QComboBox(this);
QStringList strList;
strList << QStringLiteral("样式一") << QStringLiteral("样式二") << QStringLiteral("样式三");
for (int i = 0; i < strList.count(); ++i)
{
m_comboBox->addItem(strList.at(i));
}
m_comboBox->setFixedSize(100, 25);
m_comboBox->setView(new QListView());
connect(m_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changeStyle(int)));
m_treeView = new QTreeView(this);
ItemDelegate *delegate = new ItemDelegate(this);
TreeModel *model = new TreeModel(this);
model->setXML(Util::exePath() + "/Resources/ToolsConfig.xml");
m_treeView->setHeaderHidden(true);
m_treeView->setAnimated(true);
m_treeView->setMouseTracking(true);
m_treeView->setExpandsOnDoubleClick(true);
m_treeView->setContextMenuPolicy(Qt::CustomContextMenu);
m_treeView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_treeView->setModel(model);
delegate->setView(m_treeView);
m_treeView->setItemDelegate(delegate);
connect(delegate, SIGNAL(expanded(const QModelIndex &)), this, SLOT(expanded(const QModelIndex &)));
m_label = new QLabel(this);
m_closeButton = new QPushButton(this);
m_closeButton->setFixedSize(27, 22);
m_closeButton->setObjectName("closeButton");
m_closeButton->setToolTip(QStringLiteral("关闭"));
m_label->setObjectName("titleLabel");
m_label->setText(QStringLiteral("自定义TreeView"));
QHBoxLayout *titleLayout = new QHBoxLayout();
titleLayout->addWidget(m_label);
titleLayout->addStretch();
titleLayout->addWidget(m_closeButton);
titleLayout->setSpacing(0);
titleLayout->setContentsMargins(5, 0, 5, 0);
QHBoxLayout *styleLayout = new QHBoxLayout();
styleLayout->addWidget(m_comboBox);
styleLayout->addStretch();
styleLayout->setSpacing(0);
styleLayout->setContentsMargins(20, 0, 0, 0);
QHBoxLayout *centerLayout = new QHBoxLayout();
centerLayout->addWidget(m_treeView);
centerLayout->setSpacing(0);
centerLayout->setContentsMargins(25, 0, 25, 25);
QVBoxLayout *mainLayout = new QVBoxLayout();
mainLayout->addLayout(titleLayout);
mainLayout->addLayout(styleLayout);
mainLayout->addLayout(centerLayout);
mainLayout->setSpacing(20);
mainLayout->setContentsMargins(5, 3, 5, 7);
this->setLayout(mainLayout);
QDesktopWidget *pDesktop = QApplication::desktop();
m_rect = pDesktop->availableGeometry();
connect(m_treeView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(treeViewCustomContextMenuRequested(QPoint)));
connect(m_closeButton, SIGNAL(clicked()), qApp, SLOT(quit()));
m_treeView->expandAll();
this->changeStyle(0);
}