Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. why my qtable widget slightly move on click of last column cell of it ?
Qt 6.11 is out! See what's new in the release blog

why my qtable widget slightly move on click of last column cell of it ?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
6 Posts 2 Posters 1.2k 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.
  • Q Offline
    Q Offline
    Qt embedded developer
    wrote on last edited by
    #1

    i have 2 row and 3 column Qtable widget.

    when i click on qtable widget last column it moves slightly.

    i want to disable click on it .

    means i want to use this qtable widget only for display data.

    so what i need to do to make non clickable qtable widget ?

    JonBJ 1 Reply Last reply
    0
    • Q Qt embedded developer

      @JonB Yes i have see this but when i use

      QTableWidgetItem* ptableitem1 = new QTableWidgetItem();
      ptableitem1->setFlags(Qt::NoItemFlags);
      ui->tableWidget->setItem(ui->tableWidget->rowCount()-1,1,ptableitem1);

      but this i need to use again and again for last column all cell . so is there any logic is there which will work generic way for complete QTreewidget ?

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by JonB
      #6

      @Qt-embedded-developer
      Do it in a loop over all items after you have added them. Or, write a setItem() helper or subclass your QTableWidget/QTableWidgetItems to always set the flags whenever you create a QTableWidgetItem to add into your QTableWidget. There are so many ways.

      Or, try my tableWidget->setEnabled(false) to set the whole QTableWidget disabled in one statement, if the result you get is acceptable to you.

      1 Reply Last reply
      1
      • Q Qt embedded developer

        i have 2 row and 3 column Qtable widget.

        when i click on qtable widget last column it moves slightly.

        i want to disable click on it .

        means i want to use this qtable widget only for display data.

        so what i need to do to make non clickable qtable widget ?

        JonBJ Online
        JonBJ Online
        JonB
        wrote on last edited by JonB
        #2

        @Qt-embedded-developer
        Depending on what you mean, what about QTableWidgetItem::setFlags(Qt::NoItemFlags), or maybe just flags() & ~Qt::ItemIsSelectable?

        Q 1 Reply Last reply
        0
        • JonBJ JonB

          @Qt-embedded-developer
          Depending on what you mean, what about QTableWidgetItem::setFlags(Qt::NoItemFlags), or maybe just flags() & ~Qt::ItemIsSelectable?

          Q Offline
          Q Offline
          Qt embedded developer
          wrote on last edited by Qt embedded developer
          #3

          @JonB it gives below error

          error: 'class QTableWidget' has no member named 'setFlags'
          ui->MAGNETOMETERtable_widget->setFlags(Qt::NoItemFlags);

          JonBJ 1 Reply Last reply
          0
          • Q Qt embedded developer

            @JonB it gives below error

            error: 'class QTableWidget' has no member named 'setFlags'
            ui->MAGNETOMETERtable_widget->setFlags(Qt::NoItemFlags);

            JonBJ Online
            JonBJ Online
            JonB
            wrote on last edited by JonB
            #4

            @Qt-embedded-developer
            Did you read what I typed? Or look it up? You have not done what I typed.

            If you want to do something on the whole table, try tableWidget->setEnabled(false). But it may make the table look a bit different, you'd have to try it.

            Q 1 Reply Last reply
            0
            • JonBJ JonB

              @Qt-embedded-developer
              Did you read what I typed? Or look it up? You have not done what I typed.

              If you want to do something on the whole table, try tableWidget->setEnabled(false). But it may make the table look a bit different, you'd have to try it.

              Q Offline
              Q Offline
              Qt embedded developer
              wrote on last edited by
              #5

              @JonB Yes i have see this but when i use

              QTableWidgetItem* ptableitem1 = new QTableWidgetItem();
              ptableitem1->setFlags(Qt::NoItemFlags);
              ui->tableWidget->setItem(ui->tableWidget->rowCount()-1,1,ptableitem1);

              but this i need to use again and again for last column all cell . so is there any logic is there which will work generic way for complete QTreewidget ?

              JonBJ 1 Reply Last reply
              0
              • Q Qt embedded developer

                @JonB Yes i have see this but when i use

                QTableWidgetItem* ptableitem1 = new QTableWidgetItem();
                ptableitem1->setFlags(Qt::NoItemFlags);
                ui->tableWidget->setItem(ui->tableWidget->rowCount()-1,1,ptableitem1);

                but this i need to use again and again for last column all cell . so is there any logic is there which will work generic way for complete QTreewidget ?

                JonBJ Online
                JonBJ Online
                JonB
                wrote on last edited by JonB
                #6

                @Qt-embedded-developer
                Do it in a loop over all items after you have added them. Or, write a setItem() helper or subclass your QTableWidget/QTableWidgetItems to always set the flags whenever you create a QTableWidgetItem to add into your QTableWidget. There are so many ways.

                Or, try my tableWidget->setEnabled(false) to set the whole QTableWidget disabled in one statement, if the result you get is acceptable to you.

                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