Results 1 to 5 of 5

Thread: Border-image not working in QWidget?

  1. #1
    Join Date
    Sep 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Border-image not working in 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 event 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?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Border-image not working in QWidget?

    Quote Originally Posted by astampor View Post
    Is there something I would need to do in the paint event to get it to display, or something else I am missing?
    Yes. You need to use QStyle API to render the PE_Widget primitive.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    85
    Thanks
    2
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Border-image not working in QWidget?


  4. #4
    Join Date
    Sep 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Border-image not working in QWidget?

    Quote Originally Posted by wysota View Post
    Yes. You need to use QStyle API to render the PE_Widget primitive.
    In the paintEvent, I am already doing this:
    Qt Code:
    1. QPainter painter(this);
    2. o.initFrom(this);
    3. style()->drawPrimitive(QStyle::PE_Widget, &o, &painter, this);
    To copy to clipboard, switch view to plain text mode 

    I needed this to get the background image to draw. Is there something else I need to add to get the border-image to draw as well?

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Border-image not working in QWidget?

    No, this should be sufficient. It could be that you can't use both the background and border image or that you are doing something else incorrectly. Does it work if you apply both the background and the border image to a plain QWidget instance?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. StyleSheets: border-image performance
    By GuS in forum Qt Programming
    Replies: 3
    Last Post: 15th May 2013, 13:42
  2. Customised QWidget border
    By chandan in forum Newbie
    Replies: 1
    Last Post: 2nd March 2011, 18:08
  3. QWidget's border style
    By luochen601 in forum Qt Programming
    Replies: 2
    Last Post: 13th September 2010, 08:17
  4. costum QWidget with border-image in style sheet
    By qt fan in forum Qt Programming
    Replies: 1
    Last Post: 25th January 2009, 21:36
  5. Showing QWidget border around the window
    By maverick_pol in forum Qt Programming
    Replies: 2
    Last Post: 20th March 2008, 21:14

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.