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


C++ QScrollBar::setFocusPolicy方法代码示例

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


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

示例1: QMainWindow

ReportList::ReportList(BoxType type, bool sortByScore, QWidget *parent)
    : QMainWindow(parent)
{
    this->sort = sortByScore;
    printAction = new QAction("&Print...", this);
    QMenu* fileMenu = menuBar()->addMenu("&File");
    fileMenu->addAction(printAction);
    connect(printAction, SIGNAL(triggered()), this, SLOT(print()));

    QWidget* central = new QWidget();
    this->setCentralWidget(central);

    QHBoxLayout* mainLayout = new QHBoxLayout();
    central->setLayout(mainLayout);

    this->reports = new QStackedWidget();
    int size = 0;

    if(type == employee)
    {
        employeeData = DataInterface::getEmployees();
        if(sortByScore)
        {
            this->setWindowTitle("Employee View - Sorted By Average Score");
            qSort(employeeData.begin(), employeeData.end());
        } else
        {
            this->setWindowTitle("Employee View");
        }

        size = employeeData.size();
        for(int i = 0; i < size; i++)
        {
            EmployeeReportBox* box = new EmployeeReportBox(employeeData.at(i), i, size);
            reports->addWidget(box);
        }
    } else if(type == employer)
    {
        this->setWindowTitle("Employer View");
        employerData = DataInterface::getEmployers();
        size = employerData.size();
        for(int i = 0; i < size; i++)
        {
            EmployerReportBox* box = new EmployerReportBox(employerData.at(i), i, size);
            reports->addWidget(box);
        }
    } else
    {
        QMessageBox::information(this, "Failed To Read Data", "Failed to read the data from the file.");
        return;
    }


    QScrollBar *scrollBar = new QScrollBar(Qt::Vertical);
    scrollBar->setRange(0, size - 1);
    scrollBar->setValue(0);
    scrollBar->setFocusPolicy(Qt::WheelFocus);


    connect(scrollBar, SIGNAL(valueChanged(int)), this, SLOT(moveToBox(int)));

    this->setFixedHeight(370);

    reports->setCurrentIndex(0);

    mainLayout->addWidget(reports);
    mainLayout->addWidget(scrollBar);

}
开发者ID:noahgolmant,项目名称:Employee-Evaluation,代码行数:69,代码来源:reportlist.cpp


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