我试图围绕当前小部件的角落,但它不工作,为什么?我怎样才能围绕QWidgets的角落?
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);
}
那么我该怎么做呢? – chacham15 2012-02-21 00:51:06
这是一个窗口(而不是一个父窗口内的部件)?您需要禁用窗口框架,启用透明度,然后为具有圆角边框的窗口设置遮罩。我可能能够找到我多年前使用的代码来执行此操作... – Kitsune 2012-02-21 00:55:38