Skip to content

QtWS: Super Early Bird Tickets Available!

  • QTableView does not update

    Solved General and Desktop
    4
    0 Votes
    4 Posts
    4k Views
    N

    BINGO!!!!
    I added layoutAboutToBeChanged and layoutChanged signals to my insertRows method:

    bool ExclModel::insertRows(int row, int count, const QModelIndex & parent) { bool bRet=false; if (parent.isValid()) { // we always insert at the end... cerr << "insertRows" << ", exclVec.size "<< exclVec.size() << endl; emit layoutAboutToBeChanged(); beginInsertRows(parent,row,row+count-1); int ii; for (ii=0;ii<count;ii++) { exclItem itm;itm.strtT=0.0;itm.endT=0.0; exclVec.push_back(itm); } cerr << "end insertRows" << ", exclVec.size "<< exclVec.size() << endl; endInsertRows(); emit layoutChanged(); bRet=true; } return bRet; } AFAICT, the documentation does not mention this. I *think* it says you need those signals if you are doing sorting, but under the the insertRows method it says the following:

    If you implement your own model, you can reimplement this function if you want to support insertions. Alternatively, you can provide your own API for altering the data. In either case, you will need to call beginInsertRows() and endInsertRows() to notify other components that the model has changed.

    For clarity and naive dumb-asses like me, it should explicitly state the need for layout... signals.
  • 0 Votes
    3 Posts
    994 Views
    D

    @ValentinMichelet
    Well this just made the header visible but no db data in the table anyway

  • 0 Votes
    1 Posts
    624 Views
    No one has replied
  • 0 Votes
    2 Posts
    543 Views
    SGaistS

    Hi and welcome to devnet,

    Your while loop is blocking everything. You should rather implement this asynchronously. So set rowNumber to 0 at the beginning and when you get your data and update the model then you can trigger the appropriate signals that will tell the views to refresh themselves so that rowCount and friends will be called with the newly arrived values.

    Hope it helps