Results 1 to 7 of 7

Thread: ComboBox QStyle

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 66 Times in 62 Posts

    Default Re: ComboBox QStyle

    to be more specific, try using

    void QWidget::setBackgroundRole ( QPalette::ColorRole role )

    on the view that u get from view()

  2. #2
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    101
    Thanked 15 Times in 15 Posts

    Default Re: ComboBox QStyle

    Why don't you use style sheets to customize the looks of your combo box? You could do away without any coding at all.

  3. #3
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 66 Times in 62 Posts

    Default Re: ComboBox QStyle

    i guess u chose not to do using stylesheets cuz either u hv an older version of qt..or u just didnt know u can do it other ways here is how u do using stylesheets:

    QComboBox QAbstractItemView{
    background-color: black;
    }

    for further reference: http://doc.trolltech.com/4.3/stylesheet.html

  4. #4
    Join Date
    Jan 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: ComboBox QStyle

    great, thanks guys.. turned out to be the QPalette::Base colour. I missed this little snippet in the documentation:

    Qt Code:
    1. Used mostly as the background color for text entry widgets, but can also be used
    2. for other painting - such as the background of combobox drop down lists and toolbar
    3. handles. It is usually white or another light color.
    To copy to clipboard, switch view to plain text mode 

    and no i didn't know about style sheets, will definately read up on them for my next project.. i've done too much qstyle work on this one to change over

  5. #5
    Join Date
    Aug 2009
    Posts
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11
    Thanks
    7

    Default Re: ComboBox QStyle

    I'm trying to use style sheets to add spaces before and after each drop down item so that it can be selected more easily with a finger in a touch screen but haven't found out how. Does anyone know what the right option is?

    Here's my stylesheet for QComboBox:

    Qt Code:
    1. color: white;
    2. border-color: white;
    3. background-color: qlineargradient(x1: 0, y1: 0, x2:0, y2: 1, stop: 0 beige, stop: 1 black);
    4. border: 1px solid white;
    5. border-radius: 3px;
    6. padding: 1px 18px 1px 3px;
    7. min-width: 6em;
    8. font: 15pt "Sans Serif";
    9. }
    10.  
    11. border: 2px solid darkgray;
    12. color: white;
    13. padding: 10px 10px 10px 10px;
    14. selection-background-color: lightgray;
    15. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by vkincaid; 11th January 2010 at 17:25.

Similar Threads

  1. Replies: 2
    Last Post: 18th March 2008, 15:38
  2. [Qt 4.3.1]A problem with combobox style
    By Tamara in forum Qt Programming
    Replies: 3
    Last Post: 19th September 2007, 10:49
  3. Fonts, Colors, and QStyle
    By Jimmy2775 in forum Qt Programming
    Replies: 1
    Last Post: 28th September 2006, 07:26
  4. Combobox Signals
    By b1 in forum Qt Programming
    Replies: 3
    Last Post: 1st August 2006, 10:21
  5. Filling combobox from database
    By Philip_Anselmo in forum Qt Programming
    Replies: 3
    Last Post: 11th May 2006, 17:53

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
  •  
Qt is a trademark of The Qt Company.