当前位置: 首页>>代码示例>>C++>>正文


C++ QTreeView::setAttribute方法代码示例

本文整理汇总了C++中QTreeView::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeView::setAttribute方法的具体用法?C++ QTreeView::setAttribute怎么用?C++ QTreeView::setAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QTreeView的用法示例。


在下文中一共展示了QTreeView::setAttribute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: on_actionYearlyStatistics_triggered

void MainWindow::on_actionYearlyStatistics_triggered()
{
	QTreeView *view = new QTreeView();
	QAbstractItemModel *model = new YearlyStatisticsModel();
	view->setModel(model);
	view->setWindowModality(Qt::NonModal);
	view->setMinimumWidth(600);
	view->setAttribute(Qt::WA_QuitOnClose, false);
	view->show();
}
开发者ID:levisjani,项目名称:subsurface,代码行数:10,代码来源:mainwindow.cpp

示例2: main

int main(int argc, char *argv[])
{
    Q_INIT_RESOURCE(interview);

    QApplication app(argc, argv);
    QSplitter page;

    QAbstractItemModel *data = new Model(1000, 10, &page);
    QItemSelectionModel *selections = new QItemSelectionModel(data);

    QTableView *table = new QTableView;
    table->setModel(data);
    table->setSelectionModel(selections);
    table->horizontalHeader()->setMovable(true);
    table->verticalHeader()->setMovable(true);
    // Set StaticContents to enable minimal repaints on resizes.
    table->viewport()->setAttribute(Qt::WA_StaticContents);
    page.addWidget(table);

    QTreeView *tree = new QTreeView;
    tree->setModel(data);
    tree->setSelectionModel(selections);
    tree->setUniformRowHeights(true);
    tree->header()->setStretchLastSection(false);
    tree->viewport()->setAttribute(Qt::WA_StaticContents);
    // Disable the focus rect to get minimal repaints when scrolling on Mac.
    tree->setAttribute(Qt::WA_MacShowFocusRect, false);
    page.addWidget(tree);

    QListView *list = new QListView;
    list->setModel(data);
    list->setSelectionModel(selections);
    list->setViewMode(QListView::IconMode);
    list->setSelectionMode(QAbstractItemView::ExtendedSelection);
    list->setAlternatingRowColors(false);
    list->viewport()->setAttribute(Qt::WA_StaticContents);
    list->setAttribute(Qt::WA_MacShowFocusRect, false);
    page.addWidget(list);

    page.setWindowIcon(QPixmap(":/images/interview.png"));
    page.setWindowTitle("Interview");
    page.show();

    return app.exec();
}
开发者ID:maxxant,项目名称:qt,代码行数:45,代码来源:main.cpp

示例3: QMainWindow

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    //:/image/cat.jpg

    ui->setupUi(this);

    QString imagepath = ":/new/prefix1/folder.png";
    QPixmap image0(imagepath);
    QPixmap image = image0.scaled(QSize(100,100));
    qDebug() << image.size();
    QIcon myIcon =  QIcon(image);



    QSplitter *page= new QSplitter();

    //customer
    QList<QVariant> title;
    title<<"one"<<"two";

    QList<ItemObject*> values;
    GetData(values);
    data =new ItemModel(Q_NULLPTR);
    data->setHeaderTitle(title);
    data->BindingData(values);
    selections = new QItemSelectionModel(data);

    table = new QTableView;
    table->setModel(data);
    table->setSelectionModel(selections);
    table->setItemDelegate(new MyTableViewStyleDelegate());
    table->horizontalHeader()->setSectionsMovable(true);
    table->setSelectionBehavior(QAbstractItemView::SelectRows);
    table->verticalHeader()->setSectionsMovable(true);
    table->horizontalHeader()->setStretchLastSection(true);
    // Set StaticContents to enable minimal repaints on resizes.
    table->viewport()->setAttribute(Qt::WA_StaticContents);
    table->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(table, SIGNAL(customContextMenuRequested(QPoint)),SLOT(customMenuRequested(QPoint)));

    //table->setStyleSheet("QTableView{background-color: rgb(250, 250, 115);" "alternate-background-color: rgb(141, 163, 215);}");
    //table->setItemDelegateForColumn(0,new MyLineItemDelegate());
    table->setItemDelegateForColumn(0,new CheckBoxDelegate(table));

    table->setItemDelegateForColumn(1,new ReadOnlyDelegate());
    table->setSelectionBehavior(QAbstractItemView::SelectRows);
    table->setEditTriggers(QAbstractItemView::NoEditTriggers);
    table->setIconSize(QSize(1,1));
    //header checkbox
    TableCheckedHeader *m_customHeader = NULL;
    m_customHeader = new TableCheckedHeader(Qt::Horizontal, this);
    table->setHorizontalHeader(m_customHeader);
    connect(m_customHeader, SIGNAL(toggled(bool)), this, SLOT(_headertoggled(bool)));
    page->addWidget(table);


    QTreeView *tree = new QTreeView;
    tree->setModel(data);
    tree->setSelectionModel(selections);

    tree->setUniformRowHeights(true);
    tree->header()->setStretchLastSection(false);
    tree->viewport()->setAttribute(Qt::WA_StaticContents);
    // Disable the focus rect to get minimal repaints when scrolling on Mac.
    tree->setAttribute(Qt::WA_MacShowFocusRect, false);
    page->addWidget(tree);

    list = new QListView;
    //QObject::connect(list,SIGNAL(doubleClicked(QModelIndex),this,SLOT(doubleClicked(QModelIndex))));
    list->setModel(data);
    list->setIconSize(QSize(80,80));

    list->setItemDelegate(new MyListItemDelegege());
    list->setSelectionModel(selections);
    list->setSpacing(5);
    list->setViewMode(QListView::IconMode);
    list->setDragEnabled(false);
    list->setSelectionRectVisible(false);
    //list->setSelectionMode(QAbstractItemView::ExtendedSelection);
    list->setAlternatingRowColors(false);
    list->setResizeMode(QListWidget::Adjust);
    //list->viewport()->setAttribute(Qt::WA_StaticContents);

    list->setAttribute(Qt::WA_MacShowFocusRect, true);
    //list->setItemDelegateForColumn(1,new MyLineItemDelegate());

    list->setEditTriggers(QAbstractItemView::NoEditTriggers);
    //menu
    list->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(list,SIGNAL(customContextMenuRequested(QPoint)),SLOT(CustomListMenuRequested(QPoint)));
    page->addWidget(list);




    this->setCentralWidget(page);
}
开发者ID:lpxxn,项目名称:MyQtMVDemo,代码行数:99,代码来源:mainwindow.cpp


注:本文中的QTreeView::setAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。