QWidget - set border from C++ code
Asked Answered
W

1

6

I have QWidget instance (with other QWidgets inside) in Qt 5.8 and I want to set some border around it. Is there some way to do this from C++ without affecting any of it's children and their settings and positions?

I don't want to use stylesheets and it needs to work with any system style.

Wideangle answered 19/3, 2017 at 18:15 Comment(0)
S
14

You should use QFrame which inherits QWidget.

Set Frame::Shape in the method below to QFrame::Box. This will produce borders around your Frame:

QFrame::setFrameShape(QFrame::Shape); 

Use setLineWidth to set the line width:

QFrame::setLineWidth(int); 
Sukey answered 19/3, 2017 at 18:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.