Results 1 to 2 of 2

Thread: Styling QComboBox

  1. #1
    Join Date
    Feb 2010
    Posts
    51
    Thanks
    9
    Thanked 14 Times in 4 Posts

    Default Styling QComboBox

    I'm trying to style my QCombobox with help of this guide http://pepper.troll.no/s60prerelease...zing-qcombobox

    I have two problems:

    1. I want to set the QComboBox::down-arrow image but I'm not sure how to set the right url to the image. From the root of my project the file is located in "/src/Resources/downicon.png" but is that the way I set it or should I use the path I setup in resources.qrc? The image doesn't seem to like either way.

    This is an image of my QComboBox, you can see that the arrow is missing:


    2. My other problem is that I want to style the menu that popups when the QComboBox is pressed. Now it is just black background but I want to use a lineargradient is that possible?

    This is how it looks now:



    This is the stylesheet:
    Qt Code:
    1. font-family: "Lucida Grande", Lucida, Verdana, sans-serif;
    2. border: 1px solid #D3D3D3;
    3. border-radius: 8px;
    4. background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #EEEEEE, stop: 1 #FFFFFF);
    5. color: #333;
    6. font-size: 6pt;
    7. padding: 8px;
    8. }
    9.  
    10. background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #D5D5D5, stop: 1 #EEEEEE);
    11. }
    12.  
    13. QComboBox::drop-down {
    14. border: 1px solid #D3D3D3;
    15. border-radius: 8px;
    16. }
    17.  
    18. QComboBox::down-arrow {
    19. padding: 0px 5px 0px 5px;
    20. image: url("/src/Resources/downicon.png");
    21. }
    22.  
    23.  
    24. QComboBox::down-arrow:on {
    25.  
    26. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Styling QComboBox

    To 1) I would recommend the Qt resource system. Then your url would look like that:
    css Code:
    1. image: url(":/downicon.png");
    To copy to clipboard, switch view to plain text mode 
    . But it is not working, because you have to provide a absolute path in the file or a proper relative one. (And your installation must support png)

    to 2) use
    css Code:
    1. QComboBox QListView
    2. {
    3. background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #D5D500, stop: 1 #EE00EE);
    4. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Styling QMenubar???
    By anupamgee in forum Qt Programming
    Replies: 5
    Last Post: 29th April 2009, 10:01
  2. Styling a tab bar without frame
    By longh in forum Qt Programming
    Replies: 2
    Last Post: 15th August 2008, 16:02
  3. Styling each item in a QComboBox
    By rishid in forum Qt Programming
    Replies: 2
    Last Post: 23rd February 2008, 09:10
  4. QComboBox styling
    By Oleg in forum Qt Programming
    Replies: 3
    Last Post: 25th November 2007, 23:48
  5. Styling a QComboBox
    By Enygma in forum Qt Programming
    Replies: 6
    Last Post: 23rd August 2007, 10:22

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.