开发者

Border-image not working for QWidget

I have a class derived from QWidget. When I try to use the style-sheet to set the border-image, it appears to ignore it. I am using QT 4.4 and it looks like the QWidget should support border-image. Is there something I would need to do in the paint e开发者_StackOverflowvent to get it to display, or something else I am missing?

Also, is it possible to define a series of images for the border, using border-top-left-image and the rest?


Try subclassing QFrame instead of QWidget. I've never seen a border* style sheet work on a plain QWidget.


You need to provide a paint event for your QWidget-derived-widget to make sure it loads the stylesheet.

void MyWidget::paintEvent(QPaintEvent * event)
{
    QStyleOption option;
    option.init(this);
    QPainter painter(this);
    style()->drawPrimitive(QStyle::PE_Widget, &option, &painter, this);
    QWidget::paintEvent(event);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜