Results 1 to 5 of 5

Thread: Drawing a QImage over QWidgets

  1. #1
    Join Date
    Oct 2006
    Posts
    18
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Drawing a QImage over QWidgets

    I have a window that has a button. I want to draw a QImage all over the parent, so that it covers the button's graphic. I don't want to inherit and override QPushButton's paintEvent for that, because I need the button to be drawn normally before the parent's paintEvent is called (and the reason I need that is so I get a consistent answer from QPixmap::grabWidget).
    So, any ideas how to make the Image be drawn over the children's graphics? Maybe surpress the children's paintEvent somehow?

  2. #2
    Join Date
    Sep 2006
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Drawing a QImage over QWidgets

    If the push button and the image are siblings (IE: both have the same parent), then you can use void QWidget::raise () to move the image widget to the top of the parents child stack.

    This should mean that the image widget will now be drawn in frnot of the push button.

  3. #3
    Join Date
    Oct 2006
    Posts
    18
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Drawing a QImage over QWidgets

    I'm not sure a QImage can have anything as a parent, it's not a QObject. So, they're not siblings, and playing with raise() and lower() didn't help when I tried it.

  4. #4
    Join Date
    Sep 2006
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Drawing a QImage over QWidgets

    If you are drawing within the parent widget, I don't know of any way to override the way the children paint by allowing the parent to write over them; although it could well be possible.

    What you could do, is create a customised QWidget class with an overriden paint method to draw the image and add that into your parent, making it a sibling of the item you want to draw over. This would allow you to raise() the new custom widget to be drawn over the push button (provided you resize it appropriately).

  5. #5
    Join Date
    Oct 2006
    Posts
    18
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Drawing a QImage over QWidgets

    Thanks, I'll give it a try in a couple of days.

Similar Threads

  1. [Qt4] How to load Url image into QImage?
    By Gonzalez in forum Qt Programming
    Replies: 6
    Last Post: 13th October 2014, 10:10
  2. [SOLVED] QTreeView drawing selection with icons
    By Timewarp in forum Qt Programming
    Replies: 7
    Last Post: 7th February 2013, 07:52
  3. QPainter and QImage
    By beerkg in forum Newbie
    Replies: 3
    Last Post: 7th September 2006, 14:48
  4. Drawing an arc.
    By munna in forum Qt Programming
    Replies: 6
    Last Post: 13th June 2006, 05:36
  5. Replies: 4
    Last Post: 17th January 2006, 17:46

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.