Results 1 to 5 of 5

Thread: background-image on a set of widgets

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2006
    Posts
    23
    Thanks
    4
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Android

    Default background-image on a set of widgets

    Hello,
    I've created a widget and I want to have an image on its background. But when I try to do it, the image is also draw on each child widget.
    I've tried with designer but It doesn't work either.
    I've been able to not drawing again the image on the child widgets, drawing a new image on them.

    I'll paste the code and show you some shoots.

    Qt Code:
    1. #include <QApplication>
    2. #include <QListWidget>
    3. #include <QGridLayout>
    4. #include <QWidget>
    5.  
    6. int main(int argc, char ** argv)
    7. {
    8. QApplication app( argc, argv );
    9.  
    10. QWidget widget(0);
    11. widget.setStyleSheet("background-image: url(/home/asier/imagenes/fondos/14999-Midsommarblomster.jpg)");
    12.  
    13. QGridLayout *leftLayout = new QGridLayout();
    14. leftLayout->setSpacing (0);
    15.  
    16. for( int row = 0; row < 2; row++ ) {
    17. for( int col = 0; col < 2; col++ ) {
    18.  
    19. QListWidget *wi = new QListWidget();
    20. wi->setStyleSheet("background-image: url(/home/asier/imagenes/fondos/Abetal.jpg);background-attachment: fixed");
    21.  
    22. leftLayout->addWidget( wi, row +1, col );
    23.  
    24. leftLayout->setRowStretch( row + 1, 1 );
    25. }
    26. }
    27.  
    28. widget.setLayout(leftLayout);
    29.  
    30. widget.show();
    31. return app.exec();
    32. }
    To copy to clipboard, switch view to plain text mode 

    In the first shoot you can be how the image is also drawn on each widget, the second shows the image on the background, but with a new one for each widget. And the last one, shows the desinger with blank widgets, but the preview draws again the image for each of them.

    What can I do to have the image on the background, and not on each widget?
    I don't know if It is my fault, is not implemented or if it is a bug?

    Thank you in advance!
    Asier
    Attached Images Attached Images
    Last edited by asieriko; 31st May 2008 at 15:46.

Similar Threads

  1. Replies: 3
    Last Post: 18th May 2012, 10:12
  2. Setting background image of QFrame
    By Claymore in forum Qt Programming
    Replies: 2
    Last Post: 12th February 2007, 19:50
  3. background image in QTreeView
    By momesana in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2007, 06:25
  4. Grabbing widget's background
    By jpn in forum Qt Programming
    Replies: 4
    Last Post: 14th May 2006, 07:58
  5. [QT4.1.1 XP] background image
    By incapacitant in forum Newbie
    Replies: 3
    Last Post: 1st March 2006, 13:02

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.