Results 1 to 2 of 2

Thread: QComboBox Margins

  1. #1
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Smile QComboBox Margins

    I am trying to set the margins inside a QComboBox so I can add some padding on the inside of the combo box so the longest item doesn't go from border to border. I called the function setContentsMargin( int, int, int, int ) but this doesn't seem to work. I have tried setting all 4 ints to 100 meaning I should have a giant margin, but when the combo box displays, I am lucky to have a margin of 1. I added in a resizeEvent( ) handler so I could see if the combo box was being resized anywhere else, but my qDebug statement inside the resizeEvent is only being called when I call the setContentsMargin function. Does anyone have any ideas why the setContentsMargin seems to be not working? Thanks!

  2. #2
    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: QComboBox Margins

    You might want to try a different approach. QComboBox uses an internal model-view mechanism to display data (it is really a kind of a simple view, where the model is the list of items to display). As you can access the view (which is used when the box pops up), model and the delegate, you can change the delegate or model data. If you change the delegate so that it returns bigger sizeHints (or change sizeHintRole in items), it is possible, that the width of the combobox will change too (even in "not poped-up" mode).

Similar Threads

  1. segmentation fault insert QString in QCombobox
    By regix in forum Qt Programming
    Replies: 16
    Last Post: 8th August 2006, 08:46
  2. Automatically add items to a QComboBox (Qt4)
    By darkadept in forum Qt Programming
    Replies: 2
    Last Post: 19th May 2006, 15:32
  3. QcomboBox items
    By therealjag in forum Newbie
    Replies: 5
    Last Post: 27th March 2006, 08:21
  4. QComboBox +SUSE10.0 +qt4.1 strange behavior
    By antonio.r.tome in forum Qt Programming
    Replies: 6
    Last Post: 20th March 2006, 17:49
  5. [QT3] QComboBox: Disable adding items on Enter-keypress
    By BrainB0ne in forum Qt Programming
    Replies: 7
    Last Post: 14th January 2006, 19:43

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.