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. After changing column order, cannot select whole row

After changing column order, cannot select whole row

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.4k 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.
  • A Offline
    A Offline
    ayanamirei
    wrote on last edited by
    #1

    Give a simple example, a table with column A,B,C. In the QTableView I want the displaying order is A,C,B. I used following code:

    @
    QHeaderView* header=ui->tableView->horizontalHeader();
    header->moveSection(2,1);
    @

    After that, I cannot select whole row by click the left vertical header. If comment out above code, I can select row.
    How can I get both features, need help.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Sounds like a strange behavior, can you provide a minimal example that reproduce the problem ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ayanamirei
        wrote on last edited by
        #3

        A simple test example. F20 table has 3 columns: orgid, dptno, dptname. In tableview, I need hide orgid, and switch dptno and dptname.

        If both of 'setColumnHidden' and 'moveSection' are in effect, I cannot select row, no whole row selection signal emitted. If comment any of them, it works.

        @
        void DlgScaleSetup::LoadDpt(int orgid)
        {
        QSqlTableModel* modelDpt=(QSqlTableModel*)ui->tableView_dpt->model();
        if(modelDpt==0)
        modelDpt=new QSqlTableModel(this);

        modelDpt->setTable("F20");
        modelDpt->setFilter(QString("F20.orgid=%1").arg(orgid));
        modelDpt->setEditStrategy(QSqlTableModel::OnManualSubmit);
        
        modelDpt->setHeaderData(0,Qt::Horizontal,tr("Organization"),Qt::EditRole);
        modelDpt->setHeaderData(1,Qt::Horizontal,tr("Dpt No"),Qt::EditRole);
        modelDpt->setHeaderData(2,Qt::Horizontal,tr("Dpt Name"),Qt::EditRole);
        
        modelDpt->select();
        ui->tableView_dpt->setModel(modelDpt);
        
        ui->tableView_dpt->resizeRowsToContents();
        ui->tableView_dpt->setColumnHidden(0,true);
        
        QHeaderView* header=ui->tableView_dpt->horizontalHeader();
        header->moveSection(2,1);
        

        }
        @

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Which version of Qt are you using ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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