Results 1 to 4 of 4

Thread: combobox

  1. #1
    Join Date
    Jul 2018
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: combobox

    How to automatically change the options in a second combobox based on the option chosen(output) in the first combobox.


    Added after 27 minutes:


    I want the answer in python
    Last edited by Aasikaa; 25th July 2018 at 09:59.

  2. #2
    Join Date
    Jul 2012
    Posts
    225
    Thanks
    18
    Thanked 14 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: combobox

    by connecting the first comboxes currentIndexChanged(int) signal to the second ones setCurrentIndex(int) slot

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,118
    Thanks
    235
    Thanked 656 Times in 646 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: combobox

    That works if you want the items with the same indexes to be chosen in each combobox. I think what the OP means is that the second combobox will be filled with a different list of items based on what was chosen in the first box.

    The more general solution is to write a slot that listens for the currentIndexChanged() signal. In that slot, you clear the second combobox and fill it with the correct items for whatever index was chosen in the first combobox.

    If I were to do this in python, I would create a list of lists; the first list would be index numbers from 0 to whatever. For each entry in that list, it would contain a sub-list of the entries for the second combobox. In the slot, you retrieve the sub-list for the index that was selected, and use it to fill the second combobox.

    If you can't hard-code the second combobox lists, then you'll have to use some other means to look up or retrieve the second list based on the first index.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  4. #4
    Join Date
    Jul 2018
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: combobox

    Thank you. will try these

Similar Threads

  1. Replies: 1
    Last Post: 17th April 2018, 02:13
  2. currentTextChanged ComboBox
    By luca_ in forum Qt Programming
    Replies: 1
    Last Post: 1st February 2018, 21:13
  3. how do I use comboBox
    By QT++ in forum Newbie
    Replies: 5
    Last Post: 2nd July 2013, 14:13
  4. Help ComboBox
    By vinny gracindo in forum Newbie
    Replies: 3
    Last Post: 20th November 2009, 19:41
  5. ComboBox of bmp:s
    By SailinShoes in forum Qt Programming
    Replies: 2
    Last Post: 5th March 2008, 15:22

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.