Search code examples
visual-studio-2008qt4

How to get the data from QTableWidget?


I have created a QTableWidget which contains the file name and its size. Now I need to retrieve the file name from TableWidget and need to store it in a File. Can anyone help me to how to do this?, is there any function to retrive the text from column?


Solution

  • Try using the method

    QTableWidgetItem* item(int row, int column) const
    

    Used like this:

    int row = 1;
    int col = 1;
    QTableWidgetItem* theItem = theTableWidget->item(row, col);
    

    and extract the text using QTableWidgetItem method

    QString text () const
    

    Used like this:

    QString theText = theItem->text();