Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to using Qt classes private like QSqlRelationalTableModelPrivate to my own model



  • i need to create my own model in Qt to support some features like “returning values” in firebird database and storeprocedures and etc. for this purpose I need to access private classes like “QSqlrelationalTableModelPrivate” and “QSqlTableMoelPrivate” to accessing methods in these classes.now My question is that, is there any way to accessing these classes whiteout re-implementing them in my model?

    Thanks for your answering.



  • Hi,

    Maybe this article will answer your questions about Qt architecture. It explains how D-pointer and Q-pointer are used as well as how to inherit Qt class using their D-pointer:
    https://wiki.qt.io/D-Pointer


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You can use QT += sql-private to add them but beware, these can drastically change between two Qt versions.



  • thank for your Answering
    i want to Access to data in "QSqlRelationalTableModelPrivate" class and this class define in "qsqlrelationaltablemodel.cpp" file, so how can i access to this class?


  • Lifetime Qt Champion

    What data are you interested in ?



  • @SGaist
    for example i created my own class named "dbModel" that inherited from QSqlRealationalTableModel class and also i have my own exec method to execute sql Query like insert, update and delete instead of QSqlTableModel'exec method . for this i overwrite "insertRowIntoTable()" method but i want the parent class(QSqlRealationalTableModel) does its jobs without execute the line " return QSqlTableModel::insertRowIntoTable(rec);" and instead of it i want execute my own method(exec). so if i do all jobs of QSqlRelationalTableModel i need to access to QSqlRelationalTableModel Private class and as you know this class define in "qsqlrealationaltablemodel.cpp" file, thus i can't access to it. so i hove to re-implement "QSqlRealatinalTableModel" class in my own class. now, i want to know is there any way to do this without re-implement QSqlRealatinalTableModel class.


  • Lifetime Qt Champion

    What does your custom exec method do that is different ?

    You can't call a base class method in a partial way.

    AFAIK there's not, but one possibility would to have your own build of Qt.


Log in to reply