How can I know index QTableView in QDialog ?
-
Hi!
I create QTableView in QDialog.
How can I know index QTableView in QDialog ?
qDebug return: setGeometry: Unable to set geometry 116x30+2100+419 on QWidgetWindow/'QDialogClassWindow'. Resulting geometry: 178x122+2100+419 (frame: 8, 30, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 178x122, maximum size: 16777215x16777215)QDialog dlg(this); dlg.setWindowTitle(tr("NameDialog")); QSqlTableModel *SearchTableModel = new QSqlTableModel(this); SearchTableModel ->setTable(NameTableVacancy); SearchTableModel->select(); QTableView *ActiveVacancy = new QTableView(&dlg); ActiveVacancy->setModel(SearchTableModel); ActiveVacancy->setSelectionBehavior(QAbstractItemView::SelectRows); ActiveVacancy->setSelectionMode(QAbstractItemView::SingleSelection); QDialogButtonBox *btn_box = new QDialogButtonBox(&dlg); btn_box->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(btn_box, &QDialogButtonBox::accepted, &dlg, &QDialog::accept); connect(btn_box, &QDialogButtonBox::rejected, &dlg, &QDialog::reject); QFormLayout *layout = new QFormLayout(); layout->addRow(ActiveVacancy); layout->addWidget(btn_box); dlg.setLayout(layout); // В случае, если пользователь нажал "Ok". if(dlg.exec() == QDialog::Accepted) { qDebug()<<ActiveVacancy->currentIndex(); }
-
Hi
Are you sure its that qDebug() you see it should say something about
QModelIndex
Can you try
qDebug()<< "Selected is: " << ActiveVacancy->currentIndex(); -
Sorry, it's work.
-
@Mikeeeeee
Hi that is ok. please mark as solved then.