Results 1 to 3 of 3

Thread: background image in QTreeView

  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default background image in QTreeView

    Hi,
    I am trying to set the background image of a QTreeView to a png image via Stylesheet instructions and this works somehow, but it makes the background color of the View turn transparent. If I then set the background-color to anything other than "background-color:transparent;" the background-image disappears. Comment out the background-color instruction in the code below to get the picture ...
    Is this a bug in Qt or am I doing something wrong?

    Thanx in advance
    Momesana

    p.s. I am using Qt-4.2.2
    Qt Code:
    1. #include <QApplication>
    2. #include <QtGui>
    3.  
    4. int main(int argc, char ** argv)
    5. {
    6. QApplication app(argc, argv);
    7. QTreeView * view = new QTreeView;
    8. view->resize(500, 350);
    9. view->setStyleSheet
    10. (
    11. "QTreeView {"
    12. // "background-color:white;"
    13. "background-image:url(:images/toque.png);"
    14. "background-position:bottom right;"
    15. "background-repeat:none;"
    16. "}"
    17. );
    18. view->show();
    19. return app.exec();
    20. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: background image in QTreeView

    Qt Style Sheets - List of Attributes
    QAbstractItemView, QLineEdit, QMenu, QMenuBar, and QTextEdit don't support background images.
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    momesana (6th January 2007)

  4. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: background image in QTreeView

    Quote Originally Posted by jpn View Post
    Hehe, I just realized what I was so confused about the fact that this attribute is not supported in Qt-4.2.2 even though I was sure I had seen it in some example ...
    http://www.informatik.uni-bremen.de/...ound-image.jpg

    That screenshot was taken from the Qt-4.2.0 documentation that I have on my local filesystem and use as a reference. In there, QTreeView ist explicitly given as an example for the background-image StyleSheet instruction. :-)

    Cheers
    Momesana

Similar Threads

  1. Replies: 3
    Last Post: 18th May 2012, 11:12
  2. Background image on popup menu item
    By MarkoSan in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 27th June 2006, 06:55
  3. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 17:36
  4. How to implement a ListBox with background image
    By andyyeh75 in forum Qt Programming
    Replies: 3
    Last Post: 8th March 2006, 09:55
  5. [QT4.1.1 XP] background image
    By incapacitant in forum Newbie
    Replies: 3
    Last Post: 1st March 2006, 14: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.