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. Table widget search bar doesnt update the value
Forum Updated to NodeBB v4.3 + New Features

Table widget search bar doesnt update the value

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 389 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.
  • D Offline
    D Offline
    deleted286
    wrote on last edited by
    #1

    I'm added the searching bar to my table widget. I searched something then i delete it, wrote another word but table widget doesnt update yourself, it keep the old searching items, and the new one. How can solve this problem

    void MainWindow::on_search_editingFinished()
    {
        QList<QTableWidgetItem*> arama =ui->tableWidget->findItems(ui->ara->text(), Qt::MatchContains );
        for(QTableWidgetItem* item  : arama)
        {
            qDebug() << ui->ara->text();
            ui->tableWidget->setCurrentItem(item);
           
    
        }
    
    jsulmJ 1 Reply Last reply
    0
    • D deleted286

      I'm added the searching bar to my table widget. I searched something then i delete it, wrote another word but table widget doesnt update yourself, it keep the old searching items, and the new one. How can solve this problem

      void MainWindow::on_search_editingFinished()
      {
          QList<QTableWidgetItem*> arama =ui->tableWidget->findItems(ui->ara->text(), Qt::MatchContains );
          for(QTableWidgetItem* item  : arama)
          {
              qDebug() << ui->ara->text();
              ui->tableWidget->setCurrentItem(item);
             
      
          }
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @suslucoder Does the table contain the new string? Before starting new search you should undo the old one. Else, if the new string cannot be found you will still see the old result.

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

      D 1 Reply Last reply
      1
      • jsulmJ jsulm

        @suslucoder Does the table contain the new string? Before starting new search you should undo the old one. Else, if the new string cannot be found you will still see the old result.

        D Offline
        D Offline
        deleted286
        wrote on last edited by
        #3

        @jsulm yes the new one is on the table.
        How can i undo the old one before new search?

        jsulmJ 1 Reply Last reply
        0
        • D deleted286

          @jsulm yes the new one is on the table.
          How can i undo the old one before new search?

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

          @suslucoder Well, you have to undo ui->tableWidget->setCurrentItem(item); , right? You could use https://doc.qt.io/qt-5/qtablewidget.html#setRangeSelected to deselect everything.

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

          D 1 Reply Last reply
          3
          • jsulmJ jsulm

            @suslucoder Well, you have to undo ui->tableWidget->setCurrentItem(item); , right? You could use https://doc.qt.io/qt-5/qtablewidget.html#setRangeSelected to deselect everything.

            D Offline
            D Offline
            deleted286
            wrote on last edited by
            #5

            @jsulm i've solve it

            ui->tableWidget->clearSelection();
            

            is this a wrong usage or might it be a problem?

            jsulmJ 1 Reply Last reply
            2
            • D deleted286

              @jsulm i've solve it

              ui->tableWidget->clearSelection();
              

              is this a wrong usage or might it be a problem?

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

              @suslucoder said in Table widget search bar doesnt update the value:

              is this a wrong usage or might it be a problem?

              This is actually easier than what I suggested.

              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