#ifndef TABBAR_H
#define TABBAR_H
#include "tabbar.h"
#include <QTabWidget>
#include <QToolButton>
#include <QHBoxLayout>
#include <QLabel>
#include <QtGui/QMainWindow>
{
Q_OBJECT
public:
tabbar
(QWidget *parent
= 0, Qt
::WFlags flags
= 0) {
leftCornerWidget->setText("expanding corner widget");
rightCornerWidget->setText("fixed height corner widget");
rightCornerWidget->setFixedHeight(50);
tabWidget->setCornerWidget(leftCornerWidget, Qt::TopLeftCorner);
tabWidget->setCornerWidget(rightCornerWidget, Qt::TopRightCorner);
tabWidget
->addTab
(new QLabel("How to make a corner widget the same height as the tabs<br>that stays within the bounds of the tabbar?"),
QIcon(),
"1 tab");
tabWidget
->addTab
(new QLabel("How to make a corner widget the same height as the tabs<br>that stays within the bounds of the tabbar?"),
QIcon(),
"2 tab");
tabWidget->setStyleSheet("QTabBar::tab{ height: 50px; }");
layout->addWidget(tabWidget);
this->setLayout(layout);
resize(300,300);
show();
}
};
#endif // TABBAR_H
#ifndef TABBAR_H
#define TABBAR_H
#include "tabbar.h"
#include <QTabWidget>
#include <QToolButton>
#include <QHBoxLayout>
#include <QLabel>
#include <QtGui/QMainWindow>
class tabbar : public QWidget
{
Q_OBJECT
public:
tabbar(QWidget *parent = 0, Qt::WFlags flags = 0)
: QWidget(parent, flags)
{
QToolButton* leftCornerWidget = new QToolButton();
leftCornerWidget->setText("expanding corner widget");
leftCornerWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
QToolButton* rightCornerWidget = new QToolButton();
rightCornerWidget->setText("fixed height corner widget");
rightCornerWidget->setFixedHeight(50);
QTabWidget* tabWidget = new QTabWidget(this);
tabWidget->setCornerWidget(leftCornerWidget, Qt::TopLeftCorner);
tabWidget->setCornerWidget(rightCornerWidget, Qt::TopRightCorner);
tabWidget->addTab(new QLabel("How to make a corner widget the same height as the tabs<br>that stays within the bounds of the tabbar?"), QIcon(), "1 tab");
tabWidget->addTab(new QLabel("How to make a corner widget the same height as the tabs<br>that stays within the bounds of the tabbar?"), QIcon(), "2 tab");
tabWidget->setStyleSheet("QTabBar::tab{ height: 50px; }");
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(tabWidget);
this->setLayout(layout);
resize(300,300);
show();
}
};
#endif // TABBAR_H
To copy to clipboard, switch view to plain text mode
Bookmarks