⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 teamleadersdialog.cpp

📁 Qt4的一些例子
💻 CPP
字号:
#include <QtGui>#include "teamleadersdialog.h"TeamLeadersDialog::TeamLeadersDialog(const QStringList &leaders,                                     QWidget *parent)    : QDialog(parent){    model = new QStringListModel(this);    model->setStringList(leaders);    listView = new QListView;    listView->setModel(model);    listView->setEditTriggers(QAbstractItemView::AnyKeyPressed                              | QAbstractItemView::DoubleClicked);    insertButton = new QPushButton(tr("&Insert"));    deleteButton = new QPushButton(tr("&Delete"));    okButton = new QPushButton(tr("OK"));    okButton->setDefault(true);    cancelButton = new QPushButton(tr("Cancel"));    connect(insertButton, SIGNAL(clicked()), this, SLOT(insert()));    connect(deleteButton, SIGNAL(clicked()), this, SLOT(del()));    connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));    connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));    QHBoxLayout *buttonLayout = new QHBoxLayout;    buttonLayout->addWidget(insertButton);    buttonLayout->addWidget(deleteButton);    buttonLayout->addStretch();    buttonLayout->addWidget(okButton);    buttonLayout->addWidget(cancelButton);    QVBoxLayout *mainLayout = new QVBoxLayout;    mainLayout->addWidget(listView);    mainLayout->addLayout(buttonLayout);    setLayout(mainLayout);    setWindowTitle(tr("Team Leaders"));}QStringList TeamLeadersDialog::leaders() const{    return model->stringList();}void TeamLeadersDialog::insert(){    int row = listView->currentIndex().row();    model->insertRows(row, 1);    QModelIndex index = model->index(row);    listView->setCurrentIndex(index);    listView->edit(index);}void TeamLeadersDialog::del(){    model->removeRows(listView->currentIndex().row(), 1);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -