Hi guys im struggling with making a push button reset 6 different (but all horizontally aligned) widgets. the code im currently using is as follows:
Qt Code:
void MainWindow::on_button_clicked() { ui->lineEdit1->clear(); ui->lineEdit2->clear(); ui->combobox1->clear(); ui->lineEdit3->clear(); ui->lineEdit4->clear(); ui->combobox2->clear(); }To copy to clipboard, switch view to plain text mode
The line edits clear perfectly but the comboBoxes delete all the information I have previously keyed in. How would I instead have the pushButton reset the combobox back to the original starting selection.
eg: --- is the standard then 1, 2, 3, so i would want to go back to --- but still be able to select 1, 2, 3
Second question would be I have to do this for 20 lines, all the same as above only labeled 1 - 20 eg tMT1 - tMT20, bTN1 - bTN20. Is there a way to make the code DRY ????
Added after 1 2 minutes:
Figured it out correct code is
ui->combobox1->setCurrentIndex(WhatEverTheOriginalWas);
UPDATE
DO NOT type the selection i.e mine is ---, 1, 2, 3, etc it is 0 for ---, 1 for 1, 2 for 2, and so on
code would be
ui->combo1->setCurrentIndex(0);
(mine is 0 because i want --- to be displayed)
Bookmarks