{"id":187368,"date":"2020-11-03T23:14:20","date_gmt":"2020-11-03T15:14:20","guid":{"rendered":"http:\/\/4563.org\/?p=187368"},"modified":"2020-11-03T23:14:20","modified_gmt":"2020-11-03T15:14:20","slug":"qtabwidget-%e5%a6%82%e4%bd%95%e6%8a%8a%e6%a0%87%e7%ad%be%e9%a1%b5%e6%94%be%e5%9c%a8%e5%b7%a6%e4%be%a7","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=187368","title":{"rendered":"QTabWidget \u5982\u4f55\u628a\u6807\u7b7e\u9875\u653e\u5728\u5de6\u4fa7"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  QTabWidget \u5982\u4f55\u628a\u6807\u7b7e\u9875\u653e\u5728\u5de6\u4fa7               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : neighbads <\/span>  <span><i><\/i> 5<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u641c\u7d22\u4e86\u51e0\u4e2a\u4ee3\u7801\u5b9e\u73b0\uff0c\u663e\u793a\u6548\u679c\u90fd\u4e0d\u662f\u5f88\u7406\u60f3\u3002<\/p>\n<ul>\n<li>windows 4k Height (30)<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/11\/20201109_5fa8ec58b2075.png\" alt=\"QTabWidget \u5982\u4f55\u628a\u6807\u7b7e\u9875\u653e\u5728\u5de6\u4fa7\" \/><\/p>\n<p>\u53ef\u4ee5\u770b\u5230 \u80cc\u666f\u4e0a\u6709\u4e2a\u4e0d\u77e5\u9053\u4ec0\u4e48\u5b57\u7b26<\/p>\n<ul>\n<li>windows 4k Height (35)<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/11\/20201109_5fa8ec5d9888d.png\" alt=\"QTabWidget \u5982\u4f55\u628a\u6807\u7b7e\u9875\u653e\u5728\u5de6\u4fa7\" \/><\/p>\n<p>\u80cc\u666f\u4e0a\u7684\u5b57\u7b26\u53d8\u5c0f<\/p>\n<ul>\n<li>mac 4k Height (35)<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/11\/20201109_5fa8ec61d8d89.png\" alt=\"QTabWidget \u5982\u4f55\u628a\u6807\u7b7e\u9875\u653e\u5728\u5de6\u4fa7\" \/><\/p>\n<p>MAC \u91cc\u7b80\u76f4\u4e0d\u80fd\u770b<\/p>\n<p>\u4ee3\u7801\uff0c\u7f51\u4e0a\u641c\u5230\u7684\u57fa\u672c\u90fd\u662f\u8fd9\u6837\u4fee\u6539\u7684\uff1a<\/p>\n<p>qtabwidgetex.cpp<\/p>\n<pre><code>#include \"qtabwidgetex.h\"  QTabBarStyle::QTabBarStyle(QStyle *parent) : QProxyStyle(parent) {  }  void QTabBarStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const {     if(element == CE_TabBarTabLabel)     {         const QStyleOptionTab *tab = qstyleoption_cast&lt;const QStyleOptionTab *&gt;(option);         if(tab)         {             QStyleOptionTab opt(*tab);             opt.shape = QTabBar::RoundedNorth;             \/\/opt.icon = QIcon(\":\/res\/11.ico\");             \/\/opt.text = \"Hello\";             \/\/opt.palette.setCurrentColorGroup(QPalette::Disabled);             \/\/opt.state |= QStyle::State_Sunken;             QProxyStyle::drawControl(element, &amp;opt, painter, widget);         }     }      QProxyStyle::drawControl(element, option, painter, widget); }  QSize QTabBarStyle::sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &amp;size, const QWidget *widget) const {     QSize s = QProxyStyle::sizeFromContents(type, option, size, widget);      if(type == QStyle::CT_TabBarTab)     {         s.transpose();         s.setWidth(120);         s.setHeight(35);     }     return s; }   QTabWidgetEx::QTabWidgetEx(QWidget *parent) : QTabWidget(parent) {     m_tabbar = new QTabBar(this);     m_tabbar-&gt;setMovable(false);     m_tabbar-&gt;setStyle(new QTabBarStyle());     this-&gt;setTabBar(m_tabbar);     this-&gt;setTabPosition(QTabWidget::West); }  QTabWidgetEx::~QTabWidgetEx() {  }  <\/code><\/pre>\n<p>qtabwidgetex.h<\/p>\n<pre><code>#ifndef QTABWIDGETEX_H #define QTABWIDGETEX_H  #include &lt;QWidget&gt; #include &lt;QTabWidget&gt; #include &lt;QTableWidgetItem&gt; #include &lt;QTabBar&gt; #include &lt;QProxyStyle&gt; #include &lt;QPainter&gt;   class QTabBarStyle : public QProxyStyle {     Q_OBJECT public:     explicit QTabBarStyle(QStyle *style = nullptr);      void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const override;     QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &amp;size, const QWidget *widget) const override; };  class QTabWidgetEx : public QTabWidget {     Q_OBJECT public:     explicit QTabWidgetEx(QWidget *parent = nullptr);     ~QTabWidgetEx();  signals:  public slots:  private:     QTabBar *m_tabbar; };  #endif \/\/ QTABWIDGETEX_H  <\/code><\/pre>\n<p>\u5b8c\u6574\u5de5\u7a0b\u8fde\u63a5\uff1a https:\/\/cowtransfer.com\/s\/5add1fda5fe44b<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>0<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>QTabWidget \u5982\u4f55\u628a\u6807\u7b7e\u9875&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/187368"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=187368"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/187368\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=187368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=187368"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=187368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}