当前位置: 首页 > news >正文

复制网站源码信息流推广主要具有哪两大优势

复制网站源码,信息流推广主要具有哪两大优势,上海正规做网站公司报价,高碑店建设局网站无法通过QSS设置这些属性.要将样式更改为每个选项卡,我们必须创建一个自定义QTabBar并覆盖其paintEvent方法,以便能够更改我们使用QStyleOptionTab类的每个选项卡的样式,但是要更改QTabWidget选项卡,我们需要使用setTabBar方法但是这样是私有的,所以你需要创建一个自定义QTabWi…

无法通过QSS设置这些属性.要将样式更改为每个选项卡,我们必须创建一个自定义QTabBar并覆盖其paintEvent方法,以便能够更改我们使用QStyleOptionTab类的每个选项卡的样式,但是要更改QTabWidget选项卡,我们需要使用setTabBar方法但是这样是私有的,所以你需要创建一个自定义QTabWidget,如下所示:

tabwidget.h

#ifndef TABWIDGET_H

#define TABWIDGET_H

#include

#include

#include

class TabBar: public QTabBar

{

public:

TabBar(const QHash &colors, QWidget *parent=0):QTabBar(parent){

mColors = colors;

}

protected:

void paintEvent(QPaintEvent */*event*/){

QStylePainter painter(this);

QStyleOptionTab opt;

for(int i = 0;i < count();i++)

{

initStyleOption(&opt,i);

if(mColors.contains(opt.text)){

opt.palette.setColor(QPalette::Button, mColors[opt.text]);

}

painter.drawControl(QStyle::CE_TabBarTabShape, opt);

painter.drawControl(QStyle::CE_TabBarTabLabel,opt);

}

}

private:

QHash mColors;

};

class TabWidget : public QTabWidget

{

public:

TabWidget(QWidget *parent=0):QTabWidget(parent){

// text - color

QHash dict;

dict["All"] = QColor("yellow");

dict["purchase"] = QColor("#87ceeb");

dict["POS Sales"] = QColor("#90EE90");

dict["Cash Sales"] = QColor("pink");

dict["invoice"] = QColor("#800080");

setTabBar(new TabBar(dict));

}

};

#endif // TABWIDGET_H

要在Qt Designer的QTabWidget中使用它,我们应该提升它,我们右键单击tabwidget并选择菜单Promoted Widgets,在我的例子中,前面的代码是在tabwidget.h文件中创建的,所以这将是头文件和在Promoted Class Name的情况下,我们使用TabWidget,之后我们按下Add and Promote按钮获取下图中显示的内容:

最终结果如下图所示:

完整示例可在以下link中找到

Python:

from PyQt5 import QtGui, QtWidgets

class TabBar(QtWidgets.QTabBar):

def __init__(self, colors, parent=None):

super(TabBar, self).__init__(parent)

self.mColors = colors

def paintEvent(self, event):

painter = QtWidgets.QStylePainter(self)

opt = QtWidgets.QStyleOptionTab()

for i in range(self.count()):

self.initStyleOption(opt, i)

if opt.text in self.mColors:

opt.palette.setColor(

QtGui.QPalette.Button, self.mColors[opt.text]

)

painter.drawControl(QtWidgets.QStyle.CE_TabBarTabShape, opt)

painter.drawControl(QtWidgets.QStyle.CE_TabBarTabLabel, opt)

class TabWidget(QtWidgets.QTabWidget):

def __init__(self, parent=None):

super(TabWidget, self).__init__(parent)

d = {

"All": QtGui.QColor("yellow"),

"purchase": QtGui.QColor("#87ceeb"),

"POS Sales": QtGui.QColor("#90EE90"),

"Cash Sales": QtGui.QColor("pink"),

"invoice": QtGui.QColor("#800080"),

}

self.setTabBar(TabBar(d))

self.addTab(QtWidgets.QLabel(), "All")

self.addTab(QtWidgets.QLabel(), "purchase")

self.addTab(QtWidgets.QLabel(), "POS Sales")

self.addTab(QtWidgets.QLabel(), "Cash Sales")

self.addTab(QtWidgets.QLabel(), "invoice")

if __name__ == "__main__":

import sys

app = QtWidgets.QApplication(sys.argv)

app.setStyle("fusion")

w = TabWidget()

w.show()

sys.exit(app.exec_())

http://www.wooajung.com/news/22941.html

相关文章:

  • 福建高速公路建设指挥部网站最近一周的重大新闻
  • 是网站建设seo按照搜索引擎的什么对网站
  • 做问卷的网站好网址提交百度
  • 响应式网站多少价格seo优化招商
  • 公安门户网申请表怎么下载seo自媒体培训
  • 无备案网站微信教程推广优化网站排名
  • 明星粉丝网站怎么做太原网站建设方案咨询
  • 网站广告图怎么做衡水seo培训
  • https网站制作网络营销模式下品牌推广途径
  • 网站托管工作室营销网站的建造步骤
  • 长沙flash网站制作房产网站建设
  • 上海公安网站备案网站怎样关键词排名优化
  • 忻州网站建设企业营销型网站
  • 长沙做手机网站建设快手seo软件下载
  • 海洋cms做电影网站好做吗seo01网站
  • 上海网站开发哪里好薇什么叫外链
  • tk域名免费注册网站四川二级站seo整站优化排名
  • wordpress 个人简介 换行seo基础教程
  • 随州程力网站建设重庆seo网站排名
  • 提文成震网站狠建设g2b4b今日热点头条新闻
  • 不用代码做网站 知乎东莞网站建设
  • 接私活做网站要不要签合同html做一个简单的网页
  • 精简网站模板网页设计需要学什么软件
  • 品牌网站建设解决网站运营推广
  • 乡镇政府可以做网站认搜索引擎怎么做
  • 阳江招聘网站哪个靠谱梅州seo
  • 爱狼戈网站建设网络网站推广优化
  • 专门做学校政府的网站时事新闻最新
  • 怎么在外管局的网站做延期手机app软件开发
  • 做h5的网站有哪些网站服务器是什么意思