Results 1 to 2 of 2

Thread: How to set Default Text Statement in QComboBox

  1. #1
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    254
    Thanks
    92
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default How to set Default Text Statement in QComboBox

    How to set a default text to QComboBox. For Eg., "Select an option", as shown below

    Before :
    -----------------------
    |Select an option | V |
    -----------------------

    On Click :
    -----------------------
    |_____________ | V |
    |Option 1 |
    |Option 2 |
    |Option 3 |
    -----------------

  2. #2
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: How to set Default Text Statement in QComboBox

    Try out this:
    Qt Code:
    1. void QComboBox::setEditText ( const QString & text )
    To copy to clipboard, switch view to plain text mode 

    You might have to subclass the QComboBox to achieve the deleting when the user selects, I am not sure.
    Might be doable with the signals:
    Qt Code:
    1. void editTextChanged ( const QString & text )
    To copy to clipboard, switch view to plain text mode 
    and/or
    Qt Code:
    1. void activated ( int index )
    2. void activated ( const QString & text )
    To copy to clipboard, switch view to plain text mode 

    I am not sure if this works, but it might be worth a try.
    http://qt-project.org/doc/qt-4.8/qcombobox.html is your friend :-)

  3. The following user says thank you to sedi for this useful post:

    rawfool (26th April 2012)

Similar Threads

  1. Replies: 4
    Last Post: 27th April 2012, 10:12
  2. Set Default text in QCombo box
    By daarsh in forum Qt Programming
    Replies: 2
    Last Post: 11th April 2011, 10:38
  3. Combo box is not showing any text by default
    By chandan in forum Qt Programming
    Replies: 0
    Last Post: 1st February 2011, 10:43
  4. QLineEdit default text
    By Guilo in forum Qt Programming
    Replies: 5
    Last Post: 13th January 2011, 10:44
  5. Replies: 1
    Last Post: 13th June 2008, 18:58

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.