自学内容网 自学内容网

QSS 设置bug

问题描述:

在QWidget上add 一个QLabel,但是死活不生效

原因:

c++ 主程序如下:

        QWidget* LOGO = new QWidget(logo_wnd);
        LOGO->setFixedSize(logo_width, 41);
        LOGO->setObjectName("TittltLogo");

        QVBoxLayout* title_layout = new QVBoxLayout(LOGO);
        title_layout->setMargin(0);
        title_layout->setContentsMargins(QMargins(0, 0, 0, 0));
        title_layout->setSpacing(0);
        LOGO->setLayout(title_layout);

        QLabel* titleLabel = new QLabel(LOGO);
        titleLabel->setObjectName("TitleLogoLabel"); titleLabel->setAlignment(Qt::AlignCenter);
        titleLabel->setText(LanguageReader::GetInstance().GetLanguageText(MAIN_FORM, "SystemTitle"));
        titleLabel->adjustSize();
        title_layout->addWidget(titleLabel);

qss如下:QWidget  的qss设置在QLabel  的前边



QWidget#TittltLogo 
{
    background-color: transparent;
    border: none;
    //background-image: url(./Source/TittleText.png);
}

QLabel#TitleLogoLabel
{
    background-color: transparent;
    font-family: 'Microsoft YaHei';font-size: 20px; font-style: normal; font-weight: 600; color:#DCDCDC;
    border: none;
}

qss: 需要将 位置互换


QLabel#TitleLogoLabel
{
    background-color: transparent;
    font-family: 'Microsoft YaHei';font-size: 20px; font-style: normal; font-weight: 600; color:#DCDCDC;
    border: none;
}

QWidget#TittltLogo 
{
    background-color: transparent;
    border: none;
    //background-image: url(./Source/TittleText.png);
}

 不太明白....................有缘人解答下为什么?


原文地址:https://blog.csdn.net/sinat_20962951/article/details/143776788

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!