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