Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can I know index QTableView in QDialog ?
Forum Updated to NodeBB v4.3 + New Features

How can I know index QTableView in QDialog ?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 491 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mikeeeeee
    wrote on last edited by
    #1

    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();
     
            }
    
    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Are you sure its that qDebug() you see it should say something about
      QModelIndex
      Can you try
      qDebug()<< "Selected is: " << ActiveVacancy->currentIndex();

      1 Reply Last reply
      3
      • M Offline
        M Offline
        Mikeeeeee
        wrote on last edited by
        #3

        Sorry, it's work.

        mrjjM 1 Reply Last reply
        0
        • M Mikeeeeee

          Sorry, it's work.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Mikeeeeee
          Hi that is ok. please mark as solved then.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved