Results 1 to 3 of 3

Thread: Styling each item in a QComboBox

  1. #1
    Join Date
    Jan 2008
    Posts
    27
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Styling each item in a QComboBox

    Hi,

    I am using a touch screen and have some combo boxes to select settings. Problem I am having is the drop down items are too small / close together to be able to accurately select the item the user wants on the first touch.

    I tried styling the QComboBox but have not had any luck accessing each item in the QListView sub-control in the combo box.

    I tried setting a style sheet of something like:
    Qt Code:
    1. QComboBox QListView::item * { text-size: 16px; padding:4px; }
    To copy to clipboard, switch view to plain text mode 

    This did not do anything.

    Any suggestions?

    Thanks
    Last edited by jpn; 23rd February 2008 at 09:36. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2008
    Posts
    27
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Styling each item in a QComboBox

    Small update:

    Something like this works:
    Qt Code:
    1. QComboBox { text-size: 16px; }
    To copy to clipboard, switch view to plain text mode 

    I really wish I could put some padding in between items though. Think I may have found a bug with the style sheets, or this could be appropriate behaviour.
    If I do something like:
    Qt Code:
    1. SettingsClass s; (SettingsClass is a QWidget)
    2. s.setStyleSheet("QWidget { background: white; }");
    To copy to clipboard, switch view to plain text mode 

    It removes all the formatting I had done using QtDesigner and sets the background of all items in the widget white. Is there something I am missing with this?
    Last edited by jpn; 23rd February 2008 at 09:36. Reason: missing [code] tags

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Styling each item in a QComboBox

    If you use a touch screen and have trouble hitting widgets, maybe it would be best to change QApplication::globalStrut?

Similar Threads

  1. QComboBox item disable?
    By Equilibrium in forum Qt Programming
    Replies: 8
    Last Post: 28th November 2007, 18:41
  2. QComboBox styling
    By Oleg in forum Qt Programming
    Replies: 3
    Last Post: 26th November 2007, 00:48
  3. Styling a QComboBox
    By Enygma in forum Qt Programming
    Replies: 6
    Last Post: 23rd August 2007, 11:22
  4. Cannot select an item in QComboBox
    By Declan in forum Qt Programming
    Replies: 2
    Last Post: 19th April 2007, 09:08
  5. QComboBox and item
    By drow in forum Qt Programming
    Replies: 4
    Last Post: 14th June 2006, 10:04

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.