#define TAB_LABEL_DEFAULT_CHECKED_STYLE_SHEET "QTabBar::tab:normal{border:none;background:transparent;border-top-left-radius:8px;border-top-right-radius:8px;background: #161717;color:rgba(255,255,255,0.64);}"\ "QTabBar::tab:hover{color: #FFFFFF;background: #2E2F30;border-top-left-radius:8px;border-top-right-radius:8px;}"\ "QTabBar::tab:selected{color: #FFFFFF;background: #2E2F30;border-top-left-radius:8px;border-top-right-radius:8px;}" DefTabBar::DefTabBar(QWidget *parent) : QTabBar(parent) { m_HaveDraged = false; m_MovingWidget = new QWidget; m_MovingPic = new QLabel(m_MovingWidget); QGridLayout* layout = new QGridLayout; layout->addWidget(m_MovingPic); m_MovingWidget->setLayout(layout); QString style = "QWidget{background-color:#4ACBD6};" ; m_MovingWidget->setStyleSheet(style); m_MovingWidget->setWindowFlags(Qt::FramelessWindowHint); m_MovingWidget->setAttribute(Qt::WA_TranslucentBackground); m_MovingWidget->hide(); this->setStylesetstySheet(TAB_LABEL_DEFAULT_CHECKED_STYLE_SHEET); } setStylesetstySheet部分不生效是为什么
时间: 2024-03-27 15:41:17 浏览: 106
C++ 中pragma once 与 #ifndef _XXX_H_ #define _XXX_H_的区别
5星 · 资源好评率100%
您在代码中使用了 `setStylesetstySheet` 方法,但是正确的方法名应该是 `setStyleSheet`,这就是导致样式不生效的原因。请将以下代码中的 `setStylesetstySheet` 改为 `setStyleSheet`:
```
this->setStylesetstySheet(TAB_LABEL_DEFAULT_CHECKED_STYLE_SHEET);
```
改为:
```
this->setStyleSheet(TAB_LABEL_DEFAULT_CHECKED_STYLE_SHEET);
```
这样就可以让样式表生效了。
阅读全文