lundi 31 août 2015

how to change the text of qlineedit when Qlistview index is changed in another qdialog?

Hi i want get the text string of QListView in my main window when i click a button in Qdialog. my implementation is :

in Qdialog

void hist::getValue(){
QModelIndexList templatelist =
    ui->listView->selectionModel()->selectedIndexes();
QStringList stringlist;
foreach (const QModelIndex &index, templatelist) {
  stringlist.append(index.data(Qt::DisplayRole).toString());
 }
 qDebug()<<stringlist;
// return stringlist;   // what i need to here to return stringlist ?
}

void hist::on_downloadselected_clicked() {

connect(ui->downloadselected, SIGNAL(clicked()), SLOT(accept()));

 // TODO selected download
  }

in mainwindow

void mainwindow::on_pushButton_2_clicked()
{
hist history;
history.exec();
if( history.exec() == QDialog::Accepted ){
   QString damn = history.getValue();  // am getting error here 
   ui->url->setText(damn);
   qDebug()<<"pressed";
}
}

Aucun commentaire:

Enregistrer un commentaire