2012-02-21 55 views
2

我試圖圍繞當前小部件的角落,但它不工作,爲什麼?我怎樣才能圍繞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); 
} 

回答

2

border-radius不受QWidget的(border-styleborder-width是)的支持。檢查出the documentation。不同的小部件支持CSS屬性的不同子集。

+2

那麼我該怎麼做呢? – chacham15 2012-02-21 00:51:06

+1

這是一個窗口(而不是一個父窗口內的部件)?您需要禁用窗口框架,啓用透明度,然後爲具有圓角邊框的窗口設置遮罩。我可能能夠找到我多年前使用的代碼來執行此操作... – Kitsune 2012-02-21 00:55:38

1

QFrame支持border-radius,您還可以在可由樣式表配置的其他屬性中設置背景色。

所以我認爲設計中需要邊界半徑的部分可以是QFrame而不是QWidget。