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. Regarding Signals and Slots
Forum Updated to NodeBB v4.3 + New Features

Regarding Signals and Slots

Scheduled Pinned Locked Moved Unsolved General and Desktop
34 Posts 6 Posters 3.4k Views 2 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.
  • S Shruthi

    @JonB The user can change the value in the table widget, Based on the user entered value, the respective columns and rows value changes.

    The function is ready. But, I am not able to link both of it.

    Thank you

    T Offline
    T Offline
    TheGringerEye
    wrote on last edited by
    #5

    @Shruthi Can you record a gif video with an example?

    I try to learn English.

    1 Reply Last reply
    0
    • S Shruthi

      @JonB The user can change the value in the table widget, Based on the user entered value, the respective columns and rows value changes.

      The function is ready. But, I am not able to link both of it.

      Thank you

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

      @Shruthi said in Regarding Signals and Slots:

      @JonB The user can change the value in the table widget, Based on the user entered value, the respective columns and rows value changes.
      The function is ready. But, I am not able to link both of it.

      Given your first sentence, I do not know what your second sentence means or what the problem is.

      1 Reply Last reply
      1
      • S Offline
        S Offline
        Shruthi
        wrote on last edited by
        #7

        @TheGringerEye @JonB To make it simple,the values are prefilled in the tableWidget, once the app is launched.

        If user is not interested in the prefilled value in the tableWidget. User can change the value in the widget.

        So based on the value changed by the user, The same value needs to be copied to all rows and columns.

        Please let me know, how to solve this.

        Thank you

        mrjjM 1 Reply Last reply
        0
        • S Shruthi

          @TheGringerEye @JonB To make it simple,the values are prefilled in the tableWidget, once the app is launched.

          If user is not interested in the prefilled value in the tableWidget. User can change the value in the widget.

          So based on the value changed by the user, The same value needs to be copied to all rows and columns.

          Please let me know, how to solve this.

          Thank you

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #8

          @Shruthi
          hi
          so ONE value from ONE cell must be copied to all other cells ?

          S 1 Reply Last reply
          1
          • JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote on last edited by
            #9

            void QTableWidget::cellChanged(int row, int column)

            This signal is emitted whenever the data of the item in the cell specified by row and column has changed.

            S 1 Reply Last reply
            1
            • JoeCFDJ JoeCFD

              void QTableWidget::cellChanged(int row, int column)

              This signal is emitted whenever the data of the item in the cell specified by row and column has changed.

              S Offline
              S Offline
              Shruthi
              wrote on last edited by
              #10

              @JoeCFD Thank you. I will try this.

              1 Reply Last reply
              0
              • mrjjM mrjj

                @Shruthi
                hi
                so ONE value from ONE cell must be copied to all other cells ?

                S Offline
                S Offline
                Shruthi
                wrote on last edited by
                #11

                @mrjj yes correct.

                mrjjM 1 Reply Last reply
                0
                • S Shruthi

                  @mrjj yes correct.

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #12

                  @Shruthi

                  Ok. o.O

                  void MainWindow::on_tableWidget_itemChanged(QTableWidgetItem *item)
                  {
                      int numCols = ui->tableWidget->columnCount();
                      int numRows = ui->tableWidget->rowCount();
                      auto newValue = item->text();
                      for (int row = 0; row < numRows; ++row) {
                          for (int col = 0; col < numCols ; ++col) {
                              auto cellItem = ui->tableWidget->item(row, col);
                              if (cellItem) cellItem->setText(newValue);
                          }
                      }
                  }
                  

                  alt text

                  S 1 Reply Last reply
                  8
                  • mrjjM mrjj

                    @Shruthi

                    Ok. o.O

                    void MainWindow::on_tableWidget_itemChanged(QTableWidgetItem *item)
                    {
                        int numCols = ui->tableWidget->columnCount();
                        int numRows = ui->tableWidget->rowCount();
                        auto newValue = item->text();
                        for (int row = 0; row < numRows; ++row) {
                            for (int col = 0; col < numCols ; ++col) {
                                auto cellItem = ui->tableWidget->item(row, col);
                                if (cellItem) cellItem->setText(newValue);
                            }
                        }
                    }
                    

                    alt text

                    S Offline
                    S Offline
                    Shruthi
                    wrote on last edited by
                    #13

                    @mrjj Thank you so much. I will try this.

                    mrjjM 1 Reply Last reply
                    0
                    • S Shruthi

                      @mrjj Thank you so much. I will try this.

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #14

                      @Shruthi
                      Np. Even its a bit odd :)

                      make sure you use the itemChanged signal so it first happens when user press
                      enter.

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        Shruthi
                        wrote on last edited by
                        #15

                        @mrjj Sure I will be using itemChanged signal only. Thanks again :)

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          Shruthi
                          wrote on last edited by
                          #16

                          @mrjj I am using the same section of code which you have mentioned above, It is working. But before user changes the value in the tablewidget, it is filling with some garbage value. Please let me know,what is the issue? Our changes is interfering with the insertion step itself. How to avoid this?

                          mrjjM 1 Reply Last reply
                          0
                          • S Shruthi

                            @mrjj I am using the same section of code which you have mentioned above, It is working. But before user changes the value in the tablewidget, it is filling with some garbage value. Please let me know,what is the issue? Our changes is interfering with the insertion step itself. How to avoid this?

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #17

                            @Shruthi
                            HI
                            I think the signal will also trigger when you fill the table.

                            To avoid that.
                            Either fill the table BEFORE you connect the signal.

                            or block its signals while filling it
                            https://doc.qt.io/qt-5/qsignalblocker.html

                            S 1 Reply Last reply
                            0
                            • mrjjM mrjj

                              @Shruthi
                              HI
                              I think the signal will also trigger when you fill the table.

                              To avoid that.
                              Either fill the table BEFORE you connect the signal.

                              or block its signals while filling it
                              https://doc.qt.io/qt-5/qsignalblocker.html

                              S Offline
                              S Offline
                              Shruthi
                              wrote on last edited by
                              #18

                              @mrjj sure I will refer the link. Thank you.

                              1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                Shruthi
                                wrote on last edited by
                                #19
                                This post is deleted!
                                JonBJ 1 Reply Last reply
                                0
                                • S Shruthi

                                  This post is deleted!

                                  JonBJ Offline
                                  JonBJ Offline
                                  JonB
                                  wrote on last edited by JonB
                                  #20

                                  @Shruthi
                                  Your calls to blockSignals(false); and >blockSignals(true) are the wrong way round. You are supposed to block the signals for the duration of your changes. You also don't want to leave signals blocked when your slot exits!

                                  1 Reply Last reply
                                  1
                                  • S Offline
                                    S Offline
                                    Shruthi
                                    wrote on last edited by
                                    #21
                                    This post is deleted!
                                    JonBJ 1 Reply Last reply
                                    0
                                    • mrjjM Offline
                                      mrjjM Offline
                                      mrjj
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #22

                                      Hi
                                      if the goal is to block signals then as jonB says you must do

                                      ui->tableWidget->blockSignals(true);
                                      xxxxx
                                      ui->tableWidget->blockSignals(false);

                                      not reverse

                                      1 Reply Last reply
                                      1
                                      • S Shruthi

                                        This post is deleted!

                                        JonBJ Offline
                                        JonBJ Offline
                                        JonB
                                        wrote on last edited by
                                        #23

                                        @Shruthi
                                        As @mrjj has just said. All you were supposed to do was swap one false with one true.

                                        1 Reply Last reply
                                        1
                                        • S Offline
                                          S Offline
                                          Shruthi
                                          wrote on last edited by
                                          #24

                                          @JonB @mrjj Ya I tried swapping, but it's still the same.

                                          JonBJ 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