我正试图围绕当前小部件的角落,但它不起作用,为什么?
PopupWindow::PopupWindow() : QWidget(0) {
setWindowFlags(
Qt::Tool |
Qt::FramelessWindowHint |
Qt::WindowSystemMenuHint |
Qt::WindowStaysOnTopHint
);
this->resize(300, 100);
setStyleSheet(".PopupWindow {border-style: outset;border-width: 10px;border-radius:10px;}");
QPushButton *hello = new QPushButton("Hello world!");
hello->setFont(QFont("Times", 18, QFont::Bold));
hello->setGeometry(10, 40, 180, 40);
hello->setStyleSheet("");
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(hello);
setLayout(layout);
}
答案 0 :(得分:3)
border-radius
(border-style
和border-width
)。查看the documentation。不同的小部件支持不同的CSS属性子集。
答案 1 :(得分:1)
border-radius,您还可以在样式表配置的其他属性中设置背景颜色。
所以我认为在边框中需要半径的设计部分可以是QFrame而不是QWidget。