#define TAB_LABEL_DEFAULT_CHECKED_STYLE_SHEET "QTabBar{color: #FFFFFF;background: #2E2F30;border-top-left-radius:8px;border-top-right-radius:8px;}"\ "QTabBar::close-button {image:url(:/SurveillanceSystem/Resources/VMS/close_hover.png)}"\ "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;}" TPTabBar::TPTabBar(QWidget* parent) : QTabBar(parent) { bHaveDraged = false; movingWidget = new QWidget; movingLabel = new QLabel(movingWidget); QGridLayout* layout = new QGridLayout; layout->addWidget(movingLabel); movingWidget->setLayout(layout); QString style = "QWidget{background-color:#000000};"; movingWidget->setStyleSheet(style); movingWidget->setWindowFlags(Qt::FramelessWindowHint); movingWidget->setAttribute(Qt::WA_TranslucentBackground); movingWidget->hide(); this->setStyleSheet(TAB_LABEL_DEFAULT_CHECKED_STYLE_SHEET); }setstySheet部分不生效是为什么
时间: 2024-03-27 10:41:17 浏览: 298
您在代码中使用了 `setstySheet` 方法,但是正确的方法名应该是 `setStyleSheet`,这就是导致样式不生效的原因。请将以下代码中的 `setstySheet` 改为 `setStyleSheet`:
```
this->setstySheet(TAB_LABEL_DEFAULT_CHECKED_STYLE_SHEET);
```
改为:
```
this->setStyleSheet(TAB_LABEL_DEFAULT_CHECKED_STYLE_SHEET);
```
这样就可以让样式表生效了。
相关问题
#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部分不生效是为什么
您在代码中使用了 `setStylesetstySheet` 方法,但是正确的方法名应该是 `setStyleSheet`,这就是导致样式不生效的原因。请将以下代码中的 `setStylesetstySheet` 改为 `setStyleSheet`:
```
this->setStylesetstySheet(TAB_LABEL_DEFAULT_CHECKED_STYLE_SHEET);
```
改为:
```
this->setStyleSheet(TAB_LABEL_DEFAULT_CHECKED_STYLE_SHEET);
```
这样就可以让样式表生效了。
阅读全文