资源简介

QTabWidget改变Tarbar位置并修改文字方向

资源截图

代码片段和文件信息

#include “customtabstyle.h“

CustomTabstyle::CustomTabstyle()
{

}

QSize CustomTabstyle::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();

        s.rwidth() = 105;
        s.rheight() = 40;
    }

    return s;
}

void CustomTabstyle::drawControl(ControlElement element const QstyleOption *option QPainter *painter const QWidget *widget) const
{
    if (element == CE_TabBarTabLabel)
    {
        if (const QstyleOptionTab *tab = qstyleoption_castyleOptionTab *>(option))
        {
            QTextOption option;
            option.setAlignment(Qt::AlignCenter);
            QPen pen(Qt::black 1 Qt::SolidLine Qt::RoundCap Qt::RoundJoin);
            painter->setPen(pen);

            painter->drawText(tab->rect tab->text option);


            return;
        }
    }

    QProxystyle::drawControl(element option painter widget);
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-07-11 17:30  hostPcSimulator\
     文件        1182  2017-07-11 17:26  hostPcSimulator\customtabstyle.cpp
     文件         617  2017-07-11 16:22  hostPcSimulator\customtabstyle.h
     文件        1074  2017-07-11 16:14  hostPcSimulator\hostPcSimulator.pro
     文件       44512  2017-07-11 15:59  hostPcSimulator\hostPcSimulator.pro.user
     文件         172  2017-07-11 15:52  hostPcSimulator\main.cpp
     文件         330  2017-07-11 17:29  hostPcSimulator\mainwindow.cpp
     文件         319  2017-07-11 16:25  hostPcSimulator\mainwindow.h
     文件        3195  2017-07-11 17:24  hostPcSimulator\mainwindow.ui

评论

共有 条评论