Results 1 to 7 of 7

Thread: background attribute & url to file

  1. #1

    Question background attribute & url to file

    I tried to set a background for any object type which are supported by this attribute, but failed, it works with solid colors only.

    I explored Style Sheet example and tried to apply any part of the code taken from Style Editor window, no luck.

    At first I thought that I messed up with resources and a path for the image file, but I'm sure doing right.

    It looks that Qt Designer just doesn't display the style, until it would be put into the application

  2. #2
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: background attribute & url to file

    Quote Originally Posted by Flakes View Post
    I tried to set a background for any object type which are supported by this attribute, but failed, it works with solid colors only.

    I explored Style Sheet example and tried to apply any part of the code taken from Style Editor window, no luck.

    At first I thought that I messed up with resources and a path for the image file, but I'm sure doing right.

    It looks that Qt Designer just doesn't display the style, until it would be put into the application
    In the Qt Designer you go to the property editor and choose the style sheet property and add the line as follows for image background;
    Qt Code:
    1. QDialog{background-image: url(/root/Desktop/img/plane.jpg)}
    To copy to clipboard, switch view to plain text mode 
    If you want to display this background on other widget; use QLabel, QWidget, QFrame etc. which you want in spite of QDialog.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  3. #3

    Default Re: background attribute & url to file

    didn't help

    plain QWidget, all the files in the same folder, image size 200x500




    skin.qrc
    Qt Code:
    1. <RCC>
    2. <qresource prefix="/" >
    3. <file>pic.png</file>
    4. </qresource>
    5. </RCC
    To copy to clipboard, switch view to plain text mode 
    >

  4. #4
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: background attribute & url to file

    It is working well for me. Give the absolute path for image like above I have given.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  5. #5

    Default Re: background attribute & url to file

    I'm Windows user, and the absolute path begins with C:\Documents and Settings\...
    I tried
    Qt Code:
    1. url(:/C:/Documents and Settings/...
    2. or
    3. url(/C:/Documents and Settings/...
    To copy to clipboard, switch view to plain text mode 

    no success

  6. #6

    Default Re: background attribute & url to file

    Quote Originally Posted by ashukla View Post
    It is working well for me. Give the absolute path for image like above I have given.
    I installed Qt Designer under my Ubuntu - yep, absolute path works, but it doesn't use resources, how about them?
    Last edited by Flakes; 22nd January 2008 at 21:06.

  7. #7
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: background attribute & url to file

    Quote Originally Posted by Flakes View Post
    I installed Qt Designer under my Ubuntu - yep, absolute path works, but it doesn't use resources, how about them?
    Probably, it's only work for icon setting. Because I am not seeing any way to use qrc with Style sheet.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

Similar Threads

  1. Set up the Qt4.3.2 with Visual Studio 2005
    By lamoda in forum Installation and Deployment
    Replies: 6
    Last Post: 30th January 2008, 06:51
  2. Replies: 2
    Last Post: 27th October 2007, 18:16
  3. file renaming on windows
    By jdd81 in forum Qt Programming
    Replies: 9
    Last Post: 2nd October 2007, 19:41
  4. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  5. [QT3 with XP] .png file as background to a form
    By incapacitant in forum Newbie
    Replies: 2
    Last Post: 10th February 2006, 21:20

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.