本文整理汇总了C++中QScrollArea::installEventFilter方法的典型用法代码示例。如果您正苦于以下问题:C++ QScrollArea::installEventFilter方法的具体用法?C++ QScrollArea::installEventFilter怎么用?C++ QScrollArea::installEventFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScrollArea
的用法示例。
在下文中一共展示了QScrollArea::installEventFilter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initFilesListFrame
QFrame* MainWindow::initFilesListFrame(QWidget *parent)
{
QScrollArea *scrollFrame = new QScrollArea(parent);
QFrame *frame = new QFrame(scrollFrame);
QVBoxLayout *layout = new QVBoxLayout(frame);
layout->setContentsMargins(0, 0, 0, 0);
layout->setAlignment(Qt::AlignTop);
layout->addWidget(filesListWidget);
layout->addSpacing(25);
layout->addWidget(initDragFrame(frame), 0, Qt::AlignHCenter);
layout->addSpacing(25);
scrollFrame->setWidget(frame);
scrollFrame->setAcceptDrops(true);
scrollFrame->installEventFilter(this);
scrollFrame->setWidgetResizable(true);
scrollFrame->setStyleSheet("QFrame {"
"border: none;"
"}"
"QScrollBar:vertical {"
"background: white;"
"width: 8px;"
"}"
"QScrollBar::handle:vertical {"
"background: grey;"
"min-height: 20px;"
"}"
"QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {"
"width: 0px;"
"height: 0px;"
"}");
QFrame *mainFrame = new QFrame(parent);
QVBoxLayout *mainLayout = new QVBoxLayout(mainFrame);
FixedHeaderView *headerView = new FixedHeaderView(Qt::Horizontal, mainFrame);
headerView->setModel(new FilesListModel(filesList, this));
headerView->setStyleSheet("QHeaderView::section {"
"background: transparent;"
"border-style: none;"
"border-bottom: 1px solid rgb(207, 207, 207);"
"border-right: 1px solid rgb(207, 207, 207);"
"}"
"QWidget {"
"font: bold 11px \"Arial\";"
"color: rgb(58, 58, 58);"
"}");
headerView->setFixedHeight(30);
headerView->setMinimumSectionSize(150);
headerView->resizeSection(0, 250);
headerView->resizeSection(1, 400);
headerView->setFixedHeight(30);
mainLayout->setMargin(0);
mainLayout->setSpacing(0);
mainLayout->addWidget(headerView);
mainLayout->addWidget(scrollFrame);
connect(headerView, SIGNAL(sectionResized(int,int,int)), filesListWidget, SLOT(resizeSection(int, int, int)));
connect(headerView, SIGNAL(settingsButtonClicked()), SIGNAL(incrementSettingsClicked()));
//connect(headerView, &FixedHeaderView::settingsButtonClicked, this, [=](){ initSettingsFrame(); });
connect(filesListWidget, &FilesListWidget::fileSelected, this, [=](int index)
{
if (index >= 0)
{
QRect rect = filesListWidget->visualRect(filesListWidget->currentIndex());
scrollFrame->ensureVisible(rect.x(), rect.y() + rect.height(), 0, rect.height());
}
});
return mainFrame;
}