Results 1 to 4 of 4

Thread: Add separator to QComboBox using QStringList entries

  1. #1
    Join Date
    Apr 2010
    Posts
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Add separator to QComboBox using QStringList entries

    What character, if any, is used to denote 'a separator goes here' when populating a QComboBox using QStringList entries. Most other GUI engines will replace a single underbar "_" or dash "-" with a separator.

    I want to use a separated list within a QInputDialog (see below), but can find no documentation referring to how this would be done (other than doing it long hand).

    // populate items with units of measure
    items << tr("Kilometres") << tr("Metres") << tr("Decimetres") << tr("Centimetres") << tr("Millimetres") << tr("-") << tr("Miles") << tr("Yards") << tr("Feet") << tr("Inches");

    QString item = QInputDialog::getItem(this, tr(""), tr("Unit of measure:"), items, 0, false, &ok);


    If this doesn't exist, it would make sense to add it for the next version.

    Micheal

  2. #2
    Join Date
    Nov 2010
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Add separator to QComboBox using QStringList entries

    Well, just use QComboBox::insertSeparator(int index) that would insert a separator, in your example the index would be 5, so
    Qt Code:
    1. ui->comboBox->insertSeparator(5);
    To copy to clipboard, switch view to plain text mode 
    that would make all the job

  3. #3
    Join Date
    Apr 2010
    Posts
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Add separator to QComboBox using QStringList entries

    Normally, I would. But the QInputDialog::getItem() builds the combo box directly from the QStringList. I believe this is an oversight that needs to be addressed, rather than something I am missing.

  4. #4
    Join Date
    Nov 2010
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Add separator to QComboBox using QStringList entries

    You can insert the separator after creating the combo, you will need calculate where do you want to insert it and calculate the index. just that!

Similar Threads

  1. Setting specific entries of a QComboBox to appear Bold
    By prykHetQuo in forum Qt Programming
    Replies: 7
    Last Post: 24th March 2009, 00:11
  2. separator in QComboBox
    By dyams in forum Qt Programming
    Replies: 3
    Last Post: 7th March 2008, 10:56
  3. Editing and adding entries to a QComboBox
    By bruccutler in forum Newbie
    Replies: 1
    Last Post: 29th May 2007, 18:13
  4. Replies: 7
    Last Post: 2nd June 2006, 13:48
  5. Qt4.1.1: Sorting QCombobox entries
    By Byngl in forum Qt Programming
    Replies: 4
    Last Post: 17th March 2006, 10:02

Tags for this Thread

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.