Important: Please read the Qt Code of Conduct -

Overriding QSqlTableModel::select() for MyQSqlRelationalTableModel

  • By default inheritance looks like this: ...QSqlTableModel--QSqlRelationalTableModel

    The idea is to subclass QSqlTableModel and to override QSqlTableModel::select() method like that:

    query.append(" LIMIT 10 "); //new line
    QSqlQuery qu(query, d->db);

    Also to subclass QSqlRelationalTableModel. But by subclassing QSqlRelationalTableModel it automatically inherits QSqlTableModel::select() not MyQSqlTableModel::select().

    Of course I could modify QSqlTableModel source and recompile, but this would limit portability. Is the any solution? I would like to set the number of rows to return by model.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Is it a limit that you really need on the SQL side or is it only to limit what you will be displaying ?

Log in to reply