How to create a QWidget that looks the same as the image below?
border
The widget should have just these kinds of borders, I don’t even know how to start it on the QPaintEvent
I mean how to calculate this ? this looks almost impossible to me, please any help
class Widget : public QWidget
{
Q_OBJECT
public:
Widget()
{
setStyleSheet("background-color: transparent");
setAttribute(Qt::WA_TranslucentBackground);
setWindowFlags(Qt::FramelessWindowHint);
};
void paintEvent(QPaintEvent* event) override
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
const int borderWidth = 10;
const int cornerRadius = 20;
const QColor borderColor(255, 0, 0);
QPainterPath path;
}
};
int main(int argc, char* argv[])
{
QApplication a(argc, argv);
Widget* w = new Widget;
w->show();
return a.exec();
}
New contributor
Ahalya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.