本文整理汇总了C++中QTabBar::tabAt方法的典型用法代码示例。如果您正苦于以下问题:C++ QTabBar::tabAt方法的具体用法?C++ QTabBar::tabAt怎么用?C++ QTabBar::tabAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTabBar
的用法示例。
在下文中一共展示了QTabBar::tabAt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mouseMoveEvent
void UserWidget::mouseMoveEvent( QMouseEvent *event){
QTabBar *wid = tabBar();
if(wid==0){ return; } //invalid widget found
QPoint relpos = wid->mapFromGlobal( this->mapToGlobal(event->pos()) );
//qDebug() << "Mouse Move Event: " << event->pos().x() << event->pos().y() << relpos.x() << relpos.y() << wid->width() << wid->height();
if(wid && wid->tabAt(relpos) != -1){
qDebug() << " - Mouse over tab";
this->setCurrentIndex( wid->tabAt(relpos) );
}
}
示例2: mousePressEvent
void MainTab::mousePressEvent(QMouseEvent* event)
{
if(event->buttons() == Qt::MidButton)
{
QTabBar* bar = tabBar();
m_index = bar->tabAt(bar->mapFrom(this, event->pos()));
closeTab();
}
QTabWidget::mousePressEvent(event);
}
示例3: mousePressEvent
void DocumentTabs::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::MidButton)
{
QTabBar *tabs = tabBar();
removeTab(tabs->tabAt(event->pos()));
}
QTabWidget::mousePressEvent(event);
}
示例4: contextMenuEvent
void MainTab::contextMenuEvent(QContextMenuEvent* event)
{
QTabBar* bar = tabBar();
m_index = bar->tabAt(bar->mapFrom(this, event->pos()));
if(m_index < 0)
return;
QAction* action;
QMenu menu(this);
if(m_index > 3)
{
action = menu.addAction(tr("Close tab"));
connect(action, SIGNAL(triggered()), this, SLOT(closeTab()));
}
action = menu.addAction(tr("Close all tabs"));
connect(action, SIGNAL(triggered()), this, SLOT(closeAllTabs()));
menu.exec(mapToGlobal(event->pos()));
}
示例5: eventFilter
bool FancyTabProxyStyle::eventFilter(QObject* o, QEvent* e)
{
QTabBar* bar = qobject_cast<QTabBar*>(o);
if (bar && (e->type() == QEvent::MouseMove || e->type() == QEvent::Leave)) {
QMouseEvent* event = static_cast<QMouseEvent*>(e);
const QString old_hovered_tab = bar->property("tab_hover").toString();
const QString hovered_tab = e->type() == QEvent::Leave ? QString() : bar->tabText(bar->tabAt(event->pos()));
bar->setProperty("tab_hover", hovered_tab);
if (old_hovered_tab != hovered_tab) {
bar->update();
}
}
return false;
}