Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Background image not visble



  • Hello
    I am trying to create am application where the main window shows a 'watermark' as the backgound
    Is this possible ?
    How would I go about it?

    Thanks



  • Easiest might be to use a style sheet for that.



  • Or just reimplement the paint event, create a QBrush with the image and fill the widget rect() with it - it will pattern out nicely.



  • Thanks for the replies
    Both of these methods result in a tiled effect.
    What I want to achieve is have a single image

    How can I do that



  • You can control the repeating using the background-repeat style sheet property. Or you go utcenter's way of subclassing and just do your own rendering using QPainter::drawImage in the corner you want.



  • Hi
    I have set a background image on my main window by over riding the paintEvent.
    However, if I set the background color of the widget the image is no longer visible - what do I need to do in order to be able to set a background color and have a background image?

    Thanks



  • moderators note: I have merged your two topics. Please don't just start new topics on essentially the same issue.



  • sorry, my apologies


  • Moderators

    If you re-implement paintEvent you are responsible for painting everything yourself, including background color via something like QPainter::fillRect(). If you want to stick to the default color you can call QWidget::paintEvent() at the top of your reimplemented method and then paint over the image.


Log in to reply