#include <QtGui>
#include <QWidget>
#include <QDialog>
#include <QApplication>
#include <QtWidgets>
class CustomTabStyle : public QProxyStyle
{
public:
{
QSize s
= QProxyStyle
::sizeFromContents(type, option, size, widget
);
if (type
== QStyle::CT_TabBarTab) s.transpose();
return s;
}
{
if (element == CE_TabBarTabLabel)
{
{
QProxyStyle::drawControl(element, &opt, painter, widget);
return;
}
}
QProxyStyle::drawControl(element, option, painter, widget);
}
};
int main(int argc, char *argv[], char *envp[])
{
tabWidget->tabBar()->setStyle(new CustomTabStyle);
tabWidget
->addTab
(new QWidget,
"General");
tabWidget
->addTab
(new QWidget,
"Permissions");
tabWidget
->addTab
(new QWidget,
"Applications");
mainLayout->addWidget(tabWidget);
tabWidget->show();
return app.exec();
}
#include <QtGui>
#include <QWidget>
#include <QDialog>
#include <QApplication>
#include <QtWidgets>
class CustomTabStyle : public QProxyStyle
{
public:
QSize sizeFromContents(ContentsType type, const QStyleOption *option,
const QSize &size, const QWidget *widget) const
{
QSize s = QProxyStyle::sizeFromContents(type, option, size, widget);
if (type == QStyle::CT_TabBarTab)
s.transpose();
return s;
}
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
{
if (element == CE_TabBarTabLabel)
{
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option))
{
QStyleOptionTab opt(*tab);
opt.shape = QTabBar::RoundedNorth;
QProxyStyle::drawControl(element, &opt, painter, widget);
return;
}
}
QProxyStyle::drawControl(element, option, painter, widget);
}
};
int main(int argc, char *argv[], char *envp[])
{
QApplication app(argc, argv);
QTabWidget *tabWidget = new QTabWidget;
tabWidget->setTabPosition(QTabWidget::West);
tabWidget->tabBar()->setStyle(new CustomTabStyle);
tabWidget->addTab(new QWidget, "General");
tabWidget->addTab(new QWidget, "Permissions");
tabWidget->addTab(new QWidget, "Applications");
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(tabWidget);
tabWidget->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks