Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [SOLVED] QTableWidget is not getting refreshed automatically..

    General and Desktop
    2
    5
    20185
    Loading More Posts
    • 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.
    • M
      M_31 last edited by

      Hi All,
      I am getting inputs from remote machine...if the input value is 3 , then i do draw 3 (Image)picture on my QTableWidget.

      but its not happenning automatically..if i press enter or select my QTableWidget , then only i am able to see the images..
      even after the usage of repaint(), update(), setUpdatesEnabled( ) ;...notthing was changed :-(
      my codes are
      @
      void CTestDlg::updateTableWidget()
      {
      DrawWidgetImage();

      ui->tblWidget->repaint();;
      ui->tblWidget->update();
      ui->tblWidget->setUpdatesEnabled( true ) ;
      

      }

      @

      The images are getting showed only if i press enter or select my QTableWidget , not by default..

      Please let me know whether i am doing anything wrong on this..

      1 Reply Last reply Reply Quote 0
      • G
        giesbert last edited by

        What are you doing in DrawWidgetImage?
        How do you change the content of the QTableWidget?

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

        1 Reply Last reply Reply Quote 0
        • M
          M_31 last edited by

          Inside DrawWidgetImage()..i am calling

          @
          ui->tblWidget->setItemDelegate(new NewDelegate);
          @

          and inside NewDelegate..
          @
          void NewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
          const QModelIndex &index) const
          {
          if( index.column() == 1 ) //! Result Column
          {

                      QRect rect = option.rect;
          
                      painter->save();
                      painter->setRenderHint(QPainter::Antialiasing, true);
          
                      int yOffset = (rect.height() - PaintingScaleFactor) / 2;
                      painter->translate(rect.x(), rect.y() + yOffset);
          
                      painter->drawImage(QPoint(1,0),"C:\\test.png");
                          
          
                      painter->restore();
          }
          

          }
          @

          I am able to see this image ..if i press or select my QtableWidget with my mouse button..not by default

          1 Reply Last reply Reply Quote 0
          • G
            giesbert last edited by

            So, that means, you change the painting code and it is not called?

            Repaint and update repaint the widget, not it's children. The view itself contains the viewport which really contains the painting.
            so you would need to do:

            @
            void CTestDlg::updateTableWidget()
            {
            DrawWidgetImage();
            ui->tblWidget->viewport().update();
            }
            @

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            1 Reply Last reply Reply Quote 1
            • M
              M_31 last edited by

              Wow.....Wounderfull.. :-)
              Its working now...

              Thanks for your inputs..

              1 Reply Last reply Reply Quote 0
              • First post
                Last post