本文整理汇总了C++中QTabBar::installEventFilter方法的典型用法代码示例。如果您正苦于以下问题:C++ QTabBar::installEventFilter方法的具体用法?C++ QTabBar::installEventFilter怎么用?C++ QTabBar::installEventFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTabBar
的用法示例。
在下文中一共展示了QTabBar::installEventFilter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWidget
CentralWidget::CentralWidget(QHelpEngine *engine, QWidget *parent)
: QWidget(parent)
, findBar(0)
, tabWidget(0)
, helpEngine(engine)
, printer(0)
{
lastTabPage = 0;
globalActionList.clear();
collectionFile = helpEngine->collectionFile();
QString system = QLatin1String("win");
#ifdef Q_OS_MAC
system = QLatin1String("mac");
#endif
tabWidget = new QTabWidget;
tabWidget->setDocumentMode(true);
tabWidget->setMovable(true);
connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentPageChanged(int)));
QToolButton *newTabButton = new QToolButton(this);
newTabButton->setAutoRaise(true);
newTabButton->setToolTip(tr("Add new page"));
newTabButton->setIcon(QIcon(QString::fromUtf8(":/trolltech/assistant/images/%1/addtab.png").arg(system)));
tabWidget->setCornerWidget(newTabButton, Qt::TopLeftCorner);
connect(newTabButton, SIGNAL(clicked()), this, SLOT(newTab()));
QVBoxLayout *vboxLayout = new QVBoxLayout(this);
vboxLayout->setMargin(0);
vboxLayout->addWidget(tabWidget);
QTabBar *tabBar = qFindChild<QTabBar*>(tabWidget);
if (tabBar) {
tabBar->installEventFilter(this);
tabBar->setContextMenuPolicy(Qt::CustomContextMenu);
connect(tabBar, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(showTabBarContextMenu(const QPoint&)));
}
staticCentralWidget = this;
}
示例2: QWidget
CentralWidget::CentralWidget(MainWindow *parent)
: QWidget(parent)
, lastTabPage(0)
, tabWidget(0)
, findWidget(0)
, printer(0)
, usesDefaultCollection(parent->usesDefaultCollection())
, m_searchWidget(0)
{
TRACE_OBJ
globalActionList.clear();
staticCentralWidget = this;
QVBoxLayout *vboxLayout = new QVBoxLayout(this);
QString resourcePath = QLatin1String(":/trolltech/assistant/images/");
vboxLayout->setMargin(0);
tabWidget = new QTabWidget(this);
#ifndef Q_OS_MAC
resourcePath.append(QLatin1String("win"));
#else
resourcePath.append(QLatin1String("mac"));
tabWidget->setDocumentMode(true);
#endif
connect(tabWidget, SIGNAL(currentChanged(int)), this,
SLOT(currentPageChanged(int)));
QToolButton *newTabButton = new QToolButton(this);
newTabButton->setAutoRaise(true);
newTabButton->setToolTip(tr("Add new page"));
newTabButton->setIcon(QIcon(resourcePath + QLatin1String("/addtab.png")));
tabWidget->setCornerWidget(newTabButton, Qt::TopLeftCorner);
connect(newTabButton, SIGNAL(clicked()), this, SLOT(newTab()));
QToolButton *closeTabButton = new QToolButton(this);
closeTabButton->setEnabled(false);
closeTabButton->setAutoRaise(true);
closeTabButton->setToolTip(tr("Close current page"));
closeTabButton->setIcon(QIcon(resourcePath + QLatin1String("/closetab.png")));
tabWidget->setCornerWidget(closeTabButton, Qt::TopRightCorner);
connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeTab()));
vboxLayout->addWidget(tabWidget);
findWidget = new FindWidget(this);
vboxLayout->addWidget(findWidget);
findWidget->hide();
connect(findWidget, SIGNAL(findNext()), this, SLOT(findNext()));
connect(findWidget, SIGNAL(findPrevious()), this, SLOT(findPrevious()));
connect(findWidget, SIGNAL(find(QString, bool)), this,
SLOT(find(QString, bool)));
connect(findWidget, SIGNAL(escapePressed()), this, SLOT(activateTab()));
QTabBar *tabBar = qFindChild<QTabBar*>(tabWidget);
if (tabBar) {
tabBar->installEventFilter(this);
tabBar->setContextMenuPolicy(Qt::CustomContextMenu);
connect(tabBar, SIGNAL(customContextMenuRequested(QPoint)), this,
SLOT(showTabBarContextMenu(QPoint)));
}
#if defined(QT_NO_WEBKIT)
QPalette p = palette();
p.setColor(QPalette::Inactive, QPalette::Highlight,
p.color(QPalette::Active, QPalette::Highlight));
p.setColor(QPalette::Inactive, QPalette::HighlightedText,
p.color(QPalette::Active, QPalette::HighlightedText));
setPalette(p);
#endif
}