Results 1 to 4 of 4

Thread: Need help on setting up Defult text on QCombo box

  1. #1
    Join Date
    Sep 2009
    Posts
    54
    Thanks
    4
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Need help on setting up Defult text on QCombo box

    Dear friends,
    I need Help on how to set default text to be displayed on combo box before selecting an item from it, i used the following code,
    Qt Code:
    1. cmb.addinsertItem(-1,"Select text");
    2. cmb.additem("abcdef");
    3. cmb->setCurrentIndex(-1);
    To copy to clipboard, switch view to plain text mode 
    but the "Select Text" is not displayed on the combo box by defualt, instead it is displayed as one of the item in the combo box drop down list.....

    can any one help me to solve this,
    Thanks in advance,

  2. #2
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Need help on setting up Defult text on QCombo box

    -1 is the value when no item is set. Make the current Index to '0'. And also make the 'Select Text' item index as '0' too.

  3. #3
    Join Date
    Sep 2009
    Posts
    54
    Thanks
    4
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Need help on setting up Defult text on QCombo box

    s thanks for your response nikhilqt

    i dont want to add it as an item in the combo box. is it possible to set "Select Text" as default till i select an item from combo?

  4. #4
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Need help on setting up Defult text on QCombo box

    That's what i am saying. It's your logic to do that. Check out the signals of QComboBox like currentIndexChanged(...), activated(...). On slots put your logic such that the 'Select Text' would be default option if no item is selected. Once selected remove that item from the combobox list.

  5. The following user says thank you to nikhilqt for this useful post:

    Askar (23rd February 2011)

Similar Threads

  1. Setting the text in QDomElement
    By dpatel in forum Qt Programming
    Replies: 1
    Last Post: 4th May 2010, 13:12
  2. Setting the text of a QLineEdit
    By td in forum Newbie
    Replies: 2
    Last Post: 11th September 2008, 11:03
  3. Replies: 4
    Last Post: 29th February 2008, 10:04
  4. setting text also changes color?
    By drhex in forum Qt Programming
    Replies: 5
    Last Post: 22nd November 2006, 16:36
  5. Qcombo box
    By nErnie in forum Qt Programming
    Replies: 3
    Last Post: 17th September 2006, 00:56

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.