LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   QT combobox how to save list position (https://www.linuxquestions.org/questions/programming-9/qt-combobox-how-to-save-list-position-4175499091/)

knobby67 03-22-2014 09:40 AM

QT combobox how to save list position
 
Hi All,
I've been learning QT buy setting up a demo form to fill in. I can save the answer boxes in a file and reload the answers from a file. However I've now hit a snag.
Basically I've added combo boxes, with a number of items in the drop down list. I'd like to store the selection the user has made and when they load in a file have the combobox pointing to that item in the list.
So say I have a list
"Lubuntu"
"Ubuntu"
"Debian"
"Kbuntu"
and the user chooses item 3 Debian, how can I save the position and then on loading up a file start at position "Debian" rather than "Lubuntu"

Thanks for the advise :D

dugan 03-22-2014 01:43 PM

http://qt-project.org/doc/qt-4.8/qco...rentIndex-prop

You call currentIndex() to get the current selection, and save that. When you've loaded it from the file, you call setCurrentIndex() to restore the selection.


All times are GMT -5. The time now is 03:07 PM.