QPushButton causes shadow in QFrame



  • I was hoping that QTextBrowser supported form html tags but such is not the case. So I am trying to fake it using a set of borderless QTextEdit based widgets (including one QTextbrowser) and one frame that holds the button. The reason for having more than one textedit has to do with the design so there is a reason I am doing it this way.

    Almost everything is working perfectly. The problem is that if I add the button I need to the Qframe, it does not draw the Qframe with the plain, or "sunken" appearance. There is a very light, yet noticeable shade difference between the QFrame and the rest of the widgets. How do I get the background of the frame to be completely white and borderless like everything else when the button is there? (If I DON'T add the button... it looks the way I want it too).

    Here is my code:

    @
    QFrame* bottomFrame = new QFrame(mVerticleSplitter);

    bottomFrame->setLineWidth(0); // THIS IS THE QFRAME object that has the problem
    bottomFrame->setMidLineWidth(0);
    bottomFrame->setFrameStyle(QFrame::Panel | QFrame::Sunken);
    bottomFrame->setFrameShadow(QFrame::Shadow::Sunken);
    bottomFrame->setContentsMargins(0, 0, 0, 0);

    mTitleFrame->setBackgroundRole(QPalette::Base); // a QTextEdit widget
    mTitleFrame->setLineWidth(0);
    mTitleFrame->setMidLineWidth(0);
    mTitleFrame->setFrameStyle(QFrame::Sunken);
    mTitleFrame->setContentsMargins(0, 0, 0, 0);

    mDetailBrowser->setBackgroundRole(QPalette::Base); // a QTextBrowser widget
    mDetailBrowser->setLineWidth(0);
    mDetailBrowser->setMidLineWidth(0);
    mDetailBrowser->setFrameStyle(QFrame::Sunken);
    mDetailBrowser->setContentsMargins(0, 0, 0, 0);

    mStartButton->setFixedSize(200, 30); // a QPushbotton widget
    mStartButton->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
    mStartButton->setAutoFillBackground(false);
    mStartButton->setContentsMargins(0, 0, 0, 0);

    QHBoxLayout* bottomLayout = new QHBoxLayout();
    bottomLayout->setContentsMargins(0, 0, 0, 0);
    bottomLayout->addWidget(mStartButton, 0, Qt::AlignTop | Qt::AlignCenter);
    bottomFrame->setLayout(bottomLayout);

    mHorizontalSplitter->addWidget(mTitleFrame); // borrowed minisplitter from QtCreator
    mHorizontalSplitter->addWidget(bottomFrame);
    mHorizontalSplitter->setStretchFactor(0, 3);
    mHorizontalSplitter->setStretchFactor(1, 2);

    mVerticleSplitter->addWidget(mHorizontalSplitter); // borrowed minisplitter from QtCreator
    mVerticleSplitter->addWidget(mDetailBrowser);

    QHBoxLayout* mainLayout = new QHBoxLayout();
    mainLayout->setSpacing(0);
    mainLayout->setMargin(0);
    mainLayout->addWidget(mVerticleSplitter);

    setLayout(mainLayout);
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.