remove row from table



  • I want to remove row from non sql model but I don't want to use query and removerow command is not working. Any suggestions for different approach on this?


  • Moderators

    @Suzy-Q

    You need to give more details on what Qt classes you are using.
    Probably it is also helpful to provide at least a short code snippet.



  • I have a push button delete which is called when you want to delete a selected row from a table. Here is the function for delete the row

    void frmIzlezniDokumentiPregled::deleteDok()
    {
        if(!m_OutputDocModel->removeRow(m_tableOutputDoc->currentIndex().row()))
            {
                qWarning()<<m_OutputDocModel->lastError();
            }
            slotFilterTable(); // this is for refreshing the table so I can see that the row is removed.
    }
    

    [edit:koahnig] code tags added


  • Moderators

    @Suzy-Q

    Does this code give you a warning?
    What does it say?

    What is the model class of m_OutputDocModel (if it is a derived model class what the last Qt class?) ?


  • Moderators

    @Suzy-Q

    void frmIzlezniDokumentiPregled::deleteDok()
    {
        qDebug() << "current index              " << m_tableOutputDoc->currentIndex();
        qDebug() << "current size before    " << m_tableOutputDoc->size(); 
        if(!m_OutputDocModel->removeRow(m_tableOutputDoc->currentIndex().row()))
            {
                qWarning()<< "last error " <<  m_OutputDocModel->lastError();
            }
        qDebug() << "current size before slot filter " << m_tableOutputDoc->size(); 
        slotFilterTable(); // this is for refreshing the table so I can see that the row is removed.
        qDebug() << "current size after slot filter" << m_tableOutputDoc->size(); 
    }
    

Log in to reply
 

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