[SOLVED] QTableWidget is not getting refreshed automatically..



  • 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..



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



  • 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



  • 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();
    }
    @



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

    Thanks for your inputs..


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.