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. [SOLVED] QTableWidget is not getting refreshed automatically..
Forum Update on Monday, May 27th 2025

[SOLVED] QTableWidget is not getting refreshed automatically..

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 21.5k 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.
  • M Offline
    M Offline
    M_31
    wrote on 4 Oct 2011, 11:38 last edited by
    #1

    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
    0
    • G Offline
      G Offline
      giesbert
      wrote on 4 Oct 2011, 12:51 last edited by
      #2

      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
      0
      • M Offline
        M Offline
        M_31
        wrote on 4 Oct 2011, 13:56 last edited by
        #3

        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
        0
        • G Offline
          G Offline
          giesbert
          wrote on 4 Oct 2011, 14:36 last edited by
          #4

          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
          1
          • M Offline
            M Offline
            M_31
            wrote on 4 Oct 2011, 14:44 last edited by
            #5

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

            Thanks for your inputs..

            1 Reply Last reply
            0

            1/5

            4 Oct 2011, 11:38

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved