Results 1 to 3 of 3

Thread: QTableView background image

  1. #1
    Join Date
    Jan 2012
    Location
    Canary Islands, Spain
    Posts
    86
    Thanks
    4
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default QTableView background image

    I'm trying to set a background image to a QTableView using stylesheet but doesn't seem to work.
    background-color is working ok, but background-image does nothing. I've tryed:
    Qt Code:
    1. romsList->setStyleSheet( "background-image: url( :/img/desert.jpg )" );
    2. romsList->setStyleSheet( QTableView { " background-image: url( :/img/desert.jpg )"; } );
    3. romsList->setStyleSheet( " background-image: url( QStringWithImagePath )" );
    To copy to clipboard, switch view to plain text mode 
    ...
    Is there any restriction or am i doing something wrong?

  2. #2
    Join Date
    Sep 2012
    Location
    Iran, Tehran
    Posts
    76
    Thanks
    17
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: QTableView background image

    Have you tried using absolute path of the image?

  3. #3
    Join Date
    Oct 2012
    Posts
    6
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTableView background image

    You have prefixed your image file path with a ':' which means that your application will use the associated resource file to find the image. Have you specified the your image as a resource in the .qrc file? Look here for details :
    http://doc.qt.digia.com/qt/resources.html

    Absolute paths will work but will hard code your image file path.
    Last edited by sindy; 24th October 2012 at 20:30.

Similar Threads

  1. Replies: 3
    Last Post: 3rd August 2012, 10:35
  2. Replies: 0
    Last Post: 5th April 2011, 13:36
  3. Image as a background
    By Tomasz in forum Newbie
    Replies: 5
    Last Post: 6th December 2010, 14:37
  4. Replies: 1
    Last Post: 25th June 2010, 18:31
  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.