Qt Proxy with type of source object



  • Hi,
    I have class, say MyClass, inherited from QSqlRelationalTableModel and I need to transpose it (change rows with columns). "This":http://www.qtcentre.org/wiki/index.php?title=Transpose_proxy_model solution was found. Is it possible to get object of type MyClass after transposing using the proxy? If not, are there any other ways to do it?

    Thank you!

    EDIT
    I wanna use is like this:
    @
    MyClass* myObject = new MyClass(this, db);
    TransposeProxyModel* trans = new TransposeProxyModel(this);
    trans->setSourceModel(myObject);
    ui->tableViewDb->setModel(trans);
    ui->tableViewDb->setItemDelegate(new QSqlRelationalDelegate(ui->tableViewDb));@

    It is necessary to paste object of MyClass (or QSqlRelationalTableModel) into QSqlRelationalDelegate.


  • Lifetime Qt Champion

    Hi,

    Something's not really clear, when/where would you need to get that object ?



  • [quote author="SGaist" date="1424871585"]Hi,

    Something's not really clear, when/where would you need to get that object ?[/quote]

    Hi,
    Thank you for reply!
    I wanna use is like this:
    @
    MyClass myObject = new MyClass(this, db);
    TransposeProxyModel
    trans = new TransposeProxyModel(this);
    trans->setSourceModel(myObject);
    ui->tableViewDb->setModel(trans);
    ui->tableViewDb->setItemDelegate(new QSqlRelationalDelegate(ui->tableViewDb));@

    It is necessary to paste object of MyClass (or QSqlRelationalTableModel) into QSqlRelationalDelegate.


  • Lifetime Qt Champion

    Sorry for the late reply, the delegate takes a parent in order to benefit from parent/child handling from Qt, it doesn't need to you to give him your model.


Log in to reply
 

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