Change edges of QWidget
-
Hello, I want to create a QWidget and style it the way I want. I want to change its appearance but I have no idea what to do. Can you help me?
-
Hello, I want to create a QWidget and style it the way I want. I want to change its appearance but I have no idea what to do. Can you help me?
@Joe-von-Habsburg You can override paintEvent and draw what ever you want there.
See https://stackoverflow.com/questions/71131972/how-to-draw-custom-shape-in-qt-by-using-combining-many-shapes -
Hello, I want to create a QWidget and style it the way I want. I want to change its appearance but I have no idea what to do. Can you help me?
The bottom one is easy.
Just subclassQPushButton
, implement your ownpaintEvent
and draw a circle that matches your specs.
Done.For the top button, the "WiFi"/intensity button thing:
[1] Either make a widget that internally holds threeQPushButton
widgets shaped in the way you need (also by implementingpaintEvent
)
OR
[2] you create your own button class that defines and draws these three areas and performs click-checks on them to emit your own signal depending on which section was clicked.
Something likevoid IntensityButton::clicked(int intensity)
where you pass 0, 1 or 2 or maybe even some enum class values (
LOW
,MEDIUM
,HIGH
) with your signal.The faster and simpler way is [1], [2] might take a little more effort to implement properly, but is more versatile and can be used in many ways to customize your widget even more.
Personally, I would opt for approach [2].