派生自QWidget的控件使用stylesheet

void PreviewWnd::paintEvent(QPaintEvent* ev)
{
    //從QWidget派生的窗口,若是要使用stylesheet,必需要重載paintEvent,並在函數中寫以下代碼
    QStyleOption opt;
    opt.init(this);
    QPainter p(this);
    style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}ide

相關文章
相關標籤/搜索