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

wordpress 设置404页面上海优化网站公司哪家好

wordpress 设置404页面,上海优化网站公司哪家好,网站怎么加在线客服,中国住房和城乡建设委员会网站使用QTabWidget&#xff0c;给每个tab添加了图标之后&#xff0c;文字和图标之间有间距&#xff0c;没有完美居中显示。 遇到此问题&#xff0c;尝试了多种办法&#xff0c;均不理想&#xff0c;最终自定义QTabBar&#xff0c;重绘tab&#xff0c;完美解决。 #include <QT…

使用QTabWidget,给每个tab添加了图标之后,文字和图标之间有间距,没有完美居中显示。

遇到此问题,尝试了多种办法,均不理想,最终自定义QTabBar,重绘tab,完美解决。

#include <QTabBar>
#include <QStylePainter>class MyTabBar : public QTabBar {
public:MyTabBar(QWidget *parent = nullptr) : QTabBar(parent){}protected:void paintEvent(QPaintEvent *) override{QStylePainter painter(this);for (int index = 0; index < this->count(); ++index) {QStyleOptionTab opt;initStyleOption(&opt, index);// 计算图标和文字的长度(含间距)int iconTextWidth = opt.iconSize.width()+ opt.fontMetrics.horizontalAdvance(opt.text)+ 4; // 4 是图标和文字的间距int x = (opt.rect.width() - iconTextWidth) / 2 + opt.rect.width() * index;painter.save();// 指定各状态下的按钮状态if (opt.state & QStyle::State_Selected) { // 按下状态painter.setPen(QColor(255, 255, 255));painter.fillRect(rect, QColor(31, 68, 133));} else if (opt.state & QStyle::State_MouseOver) { // 鼠标停留状态painter.setPen(QColor(255, 255, 255));painter.fillRect(rect, QColor(33, 72, 141));} else if (!(opt.state & QStyle::State_Enabled)) { // 禁止状态painter.setPen(QColor(255, 255, 255, 153));painter.fillRect(rect, QColor(84, 123, 192));} else { // 正常状态(默认)painter.setPen(QColor(255, 255, 255));painter.fillRect(rect, QColor(41, 90, 176));}QRect iconRect(x, (opt.rect.height() - opt.iconSize.height()) / 2,opt.iconSize.width(), opt.iconSize.height());painter.drawPixmap(iconRect, opt.icon.pixmap(opt.iconSize));QRect textRect(iconRect.right() + 4, 0,opt.rect.width() * (index + 1) - iconRect.right() - 4,opt.rect.height());painter.drawText(textRect, Qt::AlignVCenter | Qt::AlignLeft, opt.text);painter.restore();}}
};

调用:

ui->tabWidget->setTabBar(new MyTabBar(this));

http://www.dinnco.com/news/28854.html

相关文章:

  • wordpress开源程序建站教程搜索推广营销
  • 服装网站建设目的网站优化的关键词
  • 山东建设部网站sem 推广软件
  • 太原网站建设联系方式广告搜索引擎
  • nodejs 如何做网站后端怎样免费建立自己的网站
  • 网和网站的区别sem竞价推广怎么做
  • 西安建站海外营销
  • 备案域名购买阿里云百度seo竞价推广是什么
  • 帆布网站做哪个成都网站建设团队
  • 淘宝客网站如何做推广方案宁波seo快速排名
  • 做海报素材的网站小网站关键词搜什么
  • 网站开发代做西安seo
  • 个人网站建设 发票抖音关键词挖掘工具
  • 哈尔滨网站设计人网络营销是做什么的
  • .net core 做网站谷歌搜索官网
  • 学校网站设计的目的竞价托管优化公司
  • 仿照别人的网站做违法吗中国企业500强排行榜
  • 简易个人博客网站源码排名优化seo
  • php网站游客试用怎么做seo 最新
  • 做网站用什么程序好站长工具排名查询
  • 湖南建设信息网站百度怎么推广自己的信息
  • 网站建设合作流程图网站开发用什么软件
  • 做零食网站怎么样广州抖音推广公司
  • 网站小图标怎么做郑州网站关键词优化公司
  • 做广告的软件app有哪些站内seo和站外seo区别
  • php网站端口温州网站建设优化
  • 售后软件网站开发友情链接的作用有哪些
  • 网站建设创业百度公司招聘2022年最新招聘
  • 淘宝客手机网站做个网页需要多少钱?
  • 怎么让客户做网站软文文案案例