Basically I have a line-edit
box which take the user input such as comma separated values and on clicking the push-button
it write all the values of line-edit box to a text file. But same feature I want to achieve through combobox
. So whenever one of the item selected from combobox
it should write the contents of line-edit
box to a text file.
The code I have used so far to implement using push-button
void MainWindow::writefile()
{
QString str = ui->lineEdit->text();
QString filename = "data.txt";
QFile file(filename);
if(file.open(QIODevice::WriteOnly|QIODevice::Text))
{
QTextStream out(&file);
out<<str<<endl;
file.close();
}
}
void MainWindow::on_pushButton_clicked()
{
writefile();
}