在QDockWidget
派生類中我enable style sheet支持如下:在派生類中調用父類的繪畫事件?
void CDockWidget::paintEvent(QPaintEvent *event)
{
QStyleOption opt;
opt.initFrom(this);
QPainter p(this);
this->style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
// call QDockWidget::paintEvent(event) here ???????
// I have called QDockWidget::paintEvent(event) here, but did not notice any difference
}
問:我必須調用父類paintEvent
或這是錯的(如果是的話請詳細說明)。在原始code example父函數是不是調用,但我想知道這是否正確?它會錯過任何功能,不是嗎?
注:上述代碼允許如所描述的使用樣式表與派生類: Qt stylesheet in derived class in C++ namespace (selector)
我不知道,但我認爲你應該畫一個'將QStyle :: PE_FrameDockWidget'代替'將QStyle :: PE_Widget'的。試試看並檢查。 – Iuliu 2014-11-24 12:28:40