本文整理汇总了C++中QTabBar类的典型用法代码示例。如果您正苦于以下问题:C++ QTabBar类的具体用法?C++ QTabBar怎么用?C++ QTabBar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QTabBar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toTextEdit
void FrostEdit::widgetChanged(QWidget* old, QWidget* now) {
if(old == now)
return;
//Let's test was the last clicked widget A) TextEdit B) TabWidget C) TabBar
TextEdit* wid = toTextEdit(now);
TabWidget* tabwid = qobject_cast<TabWidget*>(now);
QTabBar* bar = qobject_cast<QTabBar*>(now) ;
//Was TabBar
if(bar != nullptr && tabwid == nullptr && wid == nullptr) {
tabwid = qobject_cast<TabWidget*>(bar->parentWidget());
updateTabWidget(tabwid);
} else if(wid != nullptr && tabwid == nullptr && bar == nullptr) {
tabwid = qobject_cast<TabWidget*>(wid->getParentWidget());
updateTabWidget(tabwid);
} else if(tabwid != nullptr && bar == nullptr) {
updateTabWidget(tabwid);
}
if(mCurrentTabWidget != nullptr) {
if(mCurrentTabWidget->count() != 0 && mCurrentTabWidget != nullptr && mCurrentTabWidget->currentWidget() != nullptr) {
QTextDocument* doc = toTextEdit(mCurrentTabWidget->currentWidget())->document();
emit documentChanged(toDocument(doc));
}
}
}
示例2: isCursorOnTabWithEmptyArea
/**
* @brief 마우스 커서가 MainWindow의 탭영역(1,2,3)에 올라가있는지 확인한다.
*
* +-------------------------------+-+-+-+
* | TITLE BAR |_|O|X|
* +----------+----------+---------+-+-+-+
* |##1(Tab)##|##2(Tab)##|###3(Empty)####|
* +----------+----------+---------------+
* | |
* | 4 |
* | |
* +-------------------------------------+
*
* TabBar::geometry()는 1,2영역을 나타내고, TabWidget::geometry()는 1,2,3,4영역을 나타낸다.
* 이 두 geometry()를 연산해서 1,2,3 영역을 찾는다.
*
* @param mainWindow 대상 메인 윈도
* @return bool
*
*/
bool CWindowManager::isCursorOnTabWithEmptyArea(MainWindow *mainWindow)
{
QRect barRect;
QRect barRectG;
QRect widgetRect;
QRect widgetRectG;
QTabBar* tabBar = 0;
QTabWidget* tabWidget = 0;
if(!mainWindow)
return false;
tabBar = mainWindow->getTabBar();
tabWidget = mainWindow->getTabWidget();
barRect = tabBar->geometry();
widgetRect = tabWidget->geometry();
barRectG.setTopLeft(tabBar->mapToGlobal(barRect.topLeft()));
barRectG.setBottomRight(tabBar->mapToGlobal(barRect.bottomRight()));
widgetRectG.setTopLeft(tabWidget->mapToGlobal(widgetRect.topLeft()));
widgetRectG.setBottomRight(tabWidget->mapToGlobal(widgetRect.bottomRight()));
widgetRectG.setTopLeft(QPoint(widgetRectG.topLeft().x(), barRectG.topLeft().y()));
widgetRectG.setBottomRight(QPoint(widgetRectG.bottomRight().x(), barRectG.bottomRight().y()));
return widgetRectG.contains(QCursor::pos());
}
示例3: QWidget
MainWidget::MainWidget(QWidget *parent) : QWidget(parent)
{
setFixedSize(1920, 1200);
setWindowTitle(tr("Babel"));
QVBoxLayout *mainLayout = new QVBoxLayout;
QTabBar *tb;
UiContact *contact = new UiContact(this);
QScrollArea *contactScrollArea = new QScrollArea();
contactScrollArea->setWidget(contact);
_tabWidget = new QTabWidget;
tb = _tabWidget->tabBar();
_tabWidget->addTab(new Home(), tr("Home"));
_tabWidget->addTab(contactScrollArea, tr("Contact"));
std::ostringstream oss;
_tabWidget->setTabsClosable(true);
connect(_tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
tb->tabButton(0, QTabBar::RightSide)->hide();
tb->tabButton(1, QTabBar::RightSide)->hide();
_tabWidget->setFocusPolicy(Qt::NoFocus);
connect(&g_PTUser, SIGNAL(receivedCall(const std::string&)), this, SLOT(receivedCall(const std::string&)));
mainLayout->addWidget(_tabWidget);
setLayout(mainLayout);
}
示例4: Q_Q
void QTabWidgetPrivate::init()
{
Q_Q(QTabWidget);
stack = new QStackedWidget(q);
stack->setObjectName(QLatin1String("qt_tabwidget_stackedwidget"));
stack->setLineWidth(0);
// hack so that QMacStyle::layoutSpacing() can detect tab widget pages
stack->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, QSizePolicy::TabWidget));
QObject::connect(stack, SIGNAL(widgetRemoved(int)), q, SLOT(_q_removeTab(int)));
QTabBar *tabBar = new QTabBar(q);
tabBar->setObjectName(QLatin1String("qt_tabwidget_tabbar"));
tabBar->setDrawBase(false);
q->setTabBar(tabBar);
q->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding,
QSizePolicy::TabWidget));
#ifdef QT_KEYPAD_NAVIGATION
if (QApplication::keypadNavigationEnabled())
q->setFocusPolicy(Qt::NoFocus);
else
#endif
q->setFocusPolicy(Qt::TabFocus);
q->setFocusProxy(tabs);
q->setTabPosition(static_cast<QTabWidget::TabPosition> (q->style()->styleHint(
QStyle::SH_TabWidget_DefaultTabPosition, 0, q )));
}
示例5: QDialog
aboutWidget::aboutWidget(QWidget *parent):
QDialog(parent),
ui(new Ui::aboutWidget)
{
setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint);
ui->setupUi(this);
ui->labAppName->setText(ui->labAppName->text() + QString(" <b>") + qApp->applicationVersion() + QString("</b>"));
QString versionInfo;
versionInfo = tr("built on ");
versionInfo.append(__DATE__);
versionInfo.append(" ");
versionInfo.append(__TIME__);
ui->labQtVer->setText(tr("using Qt ") + qVersion());
ui->labVersion->setText(versionInfo);
QTabBar *tabs = new QTabBar;
ui->frame->layout()->addWidget(tabs);
ui->frame->layout()->addWidget(ui->txtArea);
tabs->setFixedHeight(24);
tabs->insertTab(0, tr("About"));
tabs->insertTab(1, tr("Contacts"));
tabs->insertTab(2, tr("Thanks"));
connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(changeTab(int)));
ui->txtArea->setHtml(getAbouT());
}
示例6: QMainWindow
RMainWindowQt::RMainWindowQt(QWidget* parent, bool hasMdiArea) :
QMainWindow(parent), RMainWindow(), mdiArea(NULL) {
// uncomment for unified tool bars under Mac:
//#if QT_VERSION >= 0x050201
//# ifdef Q_OS_MAC
// setUnifiedTitleAndToolBarOnMac(true);
//# endif
//#endif
if (hasMdiArea) {
mdiArea = new RMdiArea(this);
mdiArea->setViewMode(QMdiArea::TabbedView);
mdiArea->setObjectName("MdiArea");
setCentralWidget(mdiArea);
// combine into one slot, locked by mutex:
connect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)),
this, SLOT(subWindowActivated(QMdiSubWindow*)));
// part of the workaround for QMdiArea bug
// with events filtering through all stacked windows:
QTabBar* tabBar = getTabBar();
if (tabBar!=NULL) {
connect(tabBar, SIGNAL(currentChanged(int)),
this, SLOT(currentTabChanged(int)));
if (RSettings::getBoolValue("Appearance/ShowAddTabButton", false)) {
tabBar->hide();
}
}
else {
示例7: GT_CHECK
void GTTabWidget::clickTab(GUITestOpStatus &os, QTabWidget* tabWidget, int idx, Qt::MouseButton button){
GT_CHECK(tabWidget != NULL, "tabWidget is NULL");
setCurrentIndex(os, tabWidget, idx);
QTabBar* tabBar = getTabBar(os, tabWidget);
QRect r = tabBar->tabRect(idx);
GTMouseDriver::moveTo(os, tabBar->mapToGlobal(r.center()));
GTMouseDriver::click(os, button);
}
示例8: QFETCH
void tst_QTabBar::setIconSize()
{
QFETCH(int, sizeToSet);
QFETCH(int, expectedWidth);
QTabBar tabBar;
tabBar.setIconSize(QSize(sizeToSet, sizeToSet));
QCOMPARE(tabBar.iconSize().width(), expectedWidth);
}
示例9: QWizard
SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf, const QString& inputMRL )
: QWizard( parent )
{
p_intf = _p_intf;
setWindowTitle( qtr( "Stream Output" ) );
setWindowRole( "vlc-stream-output" );
/* UI stuff */
ui.setupUi( this );
ui.inputBox->setMRL( inputMRL );
ui.helpEdit->setPlainText( qtr("This wizard will allow you to stream or "
"convert your media for use locally, on your private network, "
"or on the Internet.\n"
"You should start by checking that source matches what you want "
"your input to be and then press the \"Next\" "
"button to continue.\n") );
ui.mrlEdit->setToolTip ( qtr( "Stream output string.\n"
"This is automatically generated "
"when you change the above settings,\n"
"but you can change it manually." ) ) ;
ui.destTab->setTabsClosable( true );
QTabBar* tb = ui.destTab->findChild<QTabBar*>();
if( tb != NULL ) tb->tabButton(0, QTabBar::RightSide)->hide();
CONNECT( ui.destTab, tabCloseRequested( int ), this, closeTab( int ) );
ui.destTab->setTabIcon( 0, QIcon( ":/buttons/playlist/playlist_add" ) );
ui.destBox->addItem( qtr( "File" ) );
ui.destBox->addItem( "HTTP" );
ui.destBox->addItem( "MS-WMSP (MMSH)" );
ui.destBox->addItem( "RTSP" );
ui.destBox->addItem( "RTP / MPEG Transport Stream" );
ui.destBox->addItem( "RTP Audio/Video Profile" );
ui.destBox->addItem( "UDP (legacy)" );
ui.destBox->addItem( "IceCast" );
BUTTONACT( ui.addButton, addDest() );
// /* Connect everything to the updateMRL function */
#define CB( x ) CONNECT( ui.x, toggled( bool ), this, updateMRL() );
#define CT( x ) CONNECT( ui.x, textChanged( const QString& ), this, updateMRL() );
#define CS( x ) CONNECT( ui.x, valueChanged( int ), this, updateMRL() );
#define CC( x ) CONNECT( ui.x, currentIndexChanged( int ), this, updateMRL() );
/* Misc */
CB( soutAll );
CB( localOutput ); CB( transcodeBox );
CONNECT( ui.profileSelect, optionsChanged(), this, updateMRL() );
setButtonText( QWizard::FinishButton, "Stream" );
#undef CC
#undef CS
#undef CT
#undef CB
}
示例10: tabBar
void DocumentTabs::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::MidButton)
{
QTabBar *tabs = tabBar();
removeTab(tabs->tabAt(event->pos()));
}
QTabWidget::mousePressEvent(event);
}
示例11: tabBar
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) );
}
}
示例12: tabBar
void powerfulTabWidget::setNoCloseButton(int iIndex, const QSize &sizeItem)
{
QTabBar* pTabBar = tabBar();
if (NULL != pTabBar)
{
QWidget *pWidget = new QWidget;
pWidget->resize(sizeItem);
pTabBar->setTabButton(iIndex, QTabBar::RightSide, pWidget);
}
}
示例13: tabBar
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);
}
示例14: gameProcessFinished
void MainWindow::gameProcessFinished(GameProcess* process, int ) {
//ui->tabWidget->fi
int index = ui->tabWidget->indexOf(process);
//ui->tabWidget->setTabText(index, "");
if (index < 1)
return;
QTabBar* bar = ui->tabWidget->tabBar();
bar->setTabTextColor(index, Qt::red);
}
示例15: GT_CHECK_RESULT
int GTTabWidget::getTabNumByName(GUITestOpStatus &os, QTabWidget *tabWidget, QString tabName){
GT_CHECK_RESULT(tabWidget != NULL, "tabWidget is NULL", -1);
QTabBar* tabBar = getTabBar(os, tabWidget);
int num = -1;
for(int i=0; i<tabBar->count(); i++){
QString text = tabBar->tabText(i);
if(text == tabName){
num = -1;
}
}
GT_CHECK_RESULT(num != -1, "tab " + tabName + " not found", -1);
return num;
}