What palette role/attribute sets the line color of QFrame "setLineWidth" ?
-
Hello -
I am looking to change the color of the line drawn around the edge of a QFrame using this code:QFrame* frameA = new QFrame(centralWidget)
frameA->setFrameShape(QFrame::Box);
frameA->setFrameShadow(QFrame::Sunken);
frameA->setLineWidth(2);
frameA->setMidLineWidth(4);If I do this:
QBrush brush1(QColor(127, 127, 127, 255));
brush1.setStyle(Qt::SolidPattern);
palette.setBrush(QPalette::Active, QPalette::Mid, brush1);Then the line drawn for "setMindLineWidth" is grey, as expected.
But the line drawn from 'setLineWidth(2)' is always white. How do I change that color?And yes, I have don this:
QBrush brush3(QColor(255, 0, 0 255)); brush.setStyle(Qt::SolidPattern); palette.setBrush(QPalette::Active, QPalette::WindowText, brush3); palette.setBrush(QPalette::Active, QPalette::Text, brush3);I am using Qt5 and I do NOT want to use style sheet.
Operating system is Linux / XorgThanks
-
Hi,
I'm not sure I understand (a screenshot of your current result would be helpful), but I'm guessing the shadow color is what you mean.
From QFrame documentation:
QFrame::Sunken : the frame and contents appear sunken; draws a 3D sunken line using the light and dark colors of the current color group
So try this:
QFrame* frameA = new QFrame(); frameA->setFrameShape(QFrame::Box); frameA->setFrameShadow(QFrame::Sunken); frameA->setLineWidth(2); frameA->setMidLineWidth(4); QBrush brush1(QColor(127, 127, 127, 255)); brush1.setStyle(Qt::SolidPattern); QPalette palette=frameA->palette(); //shadow color, dark and light palette roles palette.setBrush(QPalette::Active, QPalette::Light, brush1); palette.setBrush(QPalette::Active, QPalette::Dark, brush1); //mid line color palette.setBrush(QPalette::Active, QPalette::Mid, brush1); frameA->setPalette(palette); frameA->show();Is this the result you're looking for?

-
Hi,
I'm not sure I understand (a screenshot of your current result would be helpful), but I'm guessing the shadow color is what you mean.
From QFrame documentation:
QFrame::Sunken : the frame and contents appear sunken; draws a 3D sunken line using the light and dark colors of the current color group
So try this:
QFrame* frameA = new QFrame(); frameA->setFrameShape(QFrame::Box); frameA->setFrameShadow(QFrame::Sunken); frameA->setLineWidth(2); frameA->setMidLineWidth(4); QBrush brush1(QColor(127, 127, 127, 255)); brush1.setStyle(Qt::SolidPattern); QPalette palette=frameA->palette(); //shadow color, dark and light palette roles palette.setBrush(QPalette::Active, QPalette::Light, brush1); palette.setBrush(QPalette::Active, QPalette::Dark, brush1); //mid line color palette.setBrush(QPalette::Active, QPalette::Mid, brush1); frameA->setPalette(palette); frameA->show();Is this the result you're looking for?

@Abderrahmene_Rayene said in What palette role/attribute sets the line color of QFrame "setLineWidth" ?:
palette.setBrush(QPalette::Active, QPalette::Light, brush1);
Yes, thank you.
So the answer to my question isalette.setBrush(QPalette::Active, QPalette::Light, brush1);
palette.setBrush(QPalette::Active, QPalette::Dark, brush1);