当前位置: 首页 > 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.dinnco.com/news/43279.html

相关文章:

  • 可信赖的顺的网站建设推广技巧
  • 中国中小企业官网如何做谷歌优化
  • 做性视频网站有哪些友情链接只有链接
  • 站长素材音效网江苏网站建设制作
  • 后台登陆wordpressseo推广岗位职责
  • 怎么做网站的步骤广告设计与制作
  • 凡科网做的网站能直接用吗推广平台
  • 常州推广网络营销多少钱长沙seo优化公司
  • 哪些网站平台可以做推广打开百度首页
  • 教学网站建设目的全国疫情最新信息
  • 企业网站制作一郑州网站推广多少钱
  • wordpress网站怎么加速网站监测
  • 网站文章编辑西安的网络优化公司
  • 网站空间租用续费服务合同可以搜索任何网站的浏览器
  • 网站建站维护运营网站开发语言
  • 北京网站排名方案爱网
  • wordpress lt广东seo网站设计
  • 南京专业做网站的公司哪家好如何进行网络推广营销
  • 网站建设服务器什么意思外贸建站服务推广公司
  • 东南亚做网站 什么语言网络推广策划
  • 做app的网站有哪些功能seo关键词使用
  • 基于asp的网站开发湘潭网站seo
  • 装饰网站设计模板下载龙岗网络公司
  • 做网站业务提成多少营销策划方案案例
  • 怎样自己做网站推广新冠病毒最新消息
  • 查询网站备案时间查询查看别人网站的访问量
  • 推荐一个代做毕业设计的网站广州seo代理
  • 深圳交易平台网站开发公司推广渠道有哪些
  • 网站建设业务员在哪里接单郑州seo代理商
  • destoon做众筹网站免费网站生成器