Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. setColumnHidden does not work

setColumnHidden does not work

Scheduled Pinned Locked Moved Unsolved Qt 6
5 Posts 3 Posters 586 Views
  • 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.
  • Y Offline
    Y Offline
    yangyanhui4
    wrote on last edited by
    #1

    hI,I have a qtableview. when I use setColumnHidden to hide a column,it works.But when I setColumnHidden (int ,false) to show it ,it fails
    if (col->isHide)
    ui->tableView->setColumnHidden(columnIndex, true);
    else
    ui->tableView->setColumnHidden(columnIndex, false);
    when the last line of code runs,nothing happened
    what may be the problem

    jsulmJ 1 Reply Last reply
    0
    • Y yangyanhui4

      hI,I have a qtableview. when I use setColumnHidden to hide a column,it works.But when I setColumnHidden (int ,false) to show it ,it fails
      if (col->isHide)
      ui->tableView->setColumnHidden(columnIndex, true);
      else
      ui->tableView->setColumnHidden(columnIndex, false);
      when the last line of code runs,nothing happened
      what may be the problem

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @yangyanhui4 said in setColumnHidden does not work:

      ui->tableView->setColumnHidden(columnIndex, false);

      You really verified that this line is executed?
      Did you also verify that columnIndex is correct?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        yangyanhui4
        wrote on last edited by
        #3

        yes,I can be sure the columnindex is true and the code runs.

        1 Reply Last reply
        0
        • Y Offline
          Y Offline
          yangyanhui4
          wrote on last edited by
          #4

          I think I find the problem.The width of the hidden column is set to zero. As a result, the column does not show.but why?when i hide a column,its width is set to zero automatically?

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Why should a column with a width of 0 be shown?
            Also you should not set a column width of 0 by yourself - use hide/show functions instead.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            1

            • Login

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