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. TableWidget Edit Diabled or Remove random rows ?

TableWidget Edit Diabled or Remove random rows ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 654 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.
  • Pranit PatilP Offline
    Pranit PatilP Offline
    Pranit Patil
    wrote on last edited by
    #1

    Using table Widget im creating One table which is contain 5 colum and several rows more than 100
    I want to disable Editable future of Table and I want to select row and delete.

    In Advance Thank U.

    @Embedded Software Developer
    God has given you one face, and you make yourself another.

    jsulmJ VRoninV 2 Replies Last reply
    0
    • Pranit PatilP Pranit Patil

      Using table Widget im creating One table which is contain 5 colum and several rows more than 100
      I want to disable Editable future of Table and I want to select row and delete.

      In Advance Thank U.

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

      @Pranit-Patil http://doc.qt.io/qt-5/qtablewidget.html#removeRow

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

      1 Reply Last reply
      2
      • Pranit PatilP Pranit Patil

        Using table Widget im creating One table which is contain 5 colum and several rows more than 100
        I want to disable Editable future of Table and I want to select row and delete.

        In Advance Thank U.

        VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        @Pranit-Patil said in TableWidget Edit Diabled or Remove random rows ?:

        I want to disable Editable future

        https://doc.qt.io/qt-5/qabstractitemview.html#editTriggers-prop

        I want to select row

        https://doc.qt.io/qt-5/qabstractitemview.html#selectionModel
        https://doc.qt.io/qt-5/qitemselectionmodel.html#selectedRows

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        2
        • Pranit PatilP Offline
          Pranit PatilP Offline
          Pranit Patil
          wrote on last edited by VRonin
          #4

          I implement like this- but in this if i click delete option created and if i clicked on delete row will be deleted
          problem is when i not selected delete option im click anywhere row will be deleted

          plz help me

          int PoMo::on_tableWidget_customContextMenuRequested(const QPoint &pos)
          {
              QMenu *menu=new QMenu(this);
              QAction *del=new QAction("delete",this);
              menu->addAction(del);
              menu->exec(QCursor::pos());
              if (DGparaCount == 1)
              {
                  no_s--;
              }
              no_p--;
              DGparaCount--;
              uiPoMo->tableWidget->removeRow(uiPoMo->tableWidget->currentRow());
              a1--;
          }
          

          @Embedded Software Developer
          God has given you one face, and you make yourself another.

          jsulmJ 1 Reply Last reply
          0
          • Pranit PatilP Pranit Patil

            I implement like this- but in this if i click delete option created and if i clicked on delete row will be deleted
            problem is when i not selected delete option im click anywhere row will be deleted

            plz help me

            int PoMo::on_tableWidget_customContextMenuRequested(const QPoint &pos)
            {
                QMenu *menu=new QMenu(this);
                QAction *del=new QAction("delete",this);
                menu->addAction(del);
                menu->exec(QCursor::pos());
                if (DGparaCount == 1)
                {
                    no_s--;
                }
                no_p--;
                DGparaCount--;
                uiPoMo->tableWidget->removeRow(uiPoMo->tableWidget->currentRow());
                a1--;
            }
            
            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Pranit-Patil Please read documentation: http://doc.qt.io/qt-5/qmenu.html#exec
            "This returns the triggered QAction in either the popup menu or one of its submenus, or 0 if no item was triggered (normally because the user pressed Esc)."
            You currently don't check whether the delete action was triggered or not.

            if (menu->exec(QCursor::pos()) != nullptr) {
                uiPoMo->tableWidget->removeRow(uiPoMo->tableWidget->currentRow());
            }

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

            1 Reply Last reply
            0
            • VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by
              #6

              Instead of uiPoMo->tableWidget->removeRow(uiPoMo->tableWidget->currentRow());
              I'd use uiPoMo->tableWidget->removeRow(uiPoMo->tableWidget->indexAt(pos).row());

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              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