Results 1 to 4 of 4

Thread: Change the value of a combobox

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Thumbs up Re: Change the value of a combobox

    hi,
    I query a database, if the current record has gender male, i want set the combobox item to "male". If the current record is gender female I want to set the combobox item to "female".
    To find the text in the combo, use findText(); this will return the index of the searched string;
    Then set the currentindex using setCurrentIndex() with the searched index.
    Qt Code:
    1. myCombo->setCurrentIndex(myCombo->findText(rs.value(0).toString()))
    To copy to clipboard, switch view to plain text mode 

    This comobobox automatically shows the first record by default. How do i change it so that the combox is blank to begin with
    simply put -1 in setCurrentIndex();
    Qt Code:
    1. myCombo->setCurrentIndex(-1);
    To copy to clipboard, switch view to plain text mode 

    How do I achieve this? I'm sure it's pretty simple, I just can't seem to get it to work.
    Just gothrough all the Qtexamples in your free time. we cant get quality results without knowing much about it

    hope it helps
    Bala
    Last edited by BalaQT; 23rd February 2011 at 13:01.

  2. The following user says thank you to BalaQT for this useful post:

    zeFree (12th September 2012)

Similar Threads

  1. Color ComboBox
    By ioannis in forum Qt Programming
    Replies: 14
    Last Post: 23rd March 2016, 07:08
  2. DockWidgetArea change and layout direction change
    By mstegehu in forum Qt Programming
    Replies: 1
    Last Post: 21st February 2012, 21:24
  3. Help ComboBox
    By vinny gracindo in forum Newbie
    Replies: 3
    Last Post: 20th November 2009, 19:41
  4. ComboBox of bmp:s
    By SailinShoes in forum Qt Programming
    Replies: 2
    Last Post: 5th March 2008, 15:22
  5. Replies: 8
    Last Post: 15th May 2007, 09:21

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
  •  
Qt is a trademark of The Qt Company.