Qt6 topics merged with General

The right way to include private h file



  • Hello!
    I try to include private h file in my project (library).

    In source code i see the line (for example)

    #include <QtSql/private/qsqldriver_p.h>
    

    But when i insert such line i have got an error

    No such file ot directory.
    

    Looks like i should add include path in the project

    C:\Qt\Qt5.5.1\5.5\mingw492_32\include\QtSql\5.5.1\ 
    

    What is the right way to do this in my library?



  • @Oleg-Zyryanov

    I add to my project file

    QT       += core gui sql sql-private core-private
    

    and include files have been resolved automatically.

    Looks like the right way.


  • Moderators

    @Oleg-Zyryanov
    Hello,

    I try to include private h file in my project (library).

    Why do you need to do that?



  • Now I try to develop my own sql driver. It is platform specific.


  • Moderators

    @Oleg-Zyryanov

    Now I try to develop my own sql driver. It is platform specific.

    Okay, this is fine, but I recon it's just better to use the public API. QSqlDriver and QSqlResult are both abstract, so why not derive from them and implement the methods? I was asking because I'm unsure whether you're aware of the implications following the usage of the private API. For example, by using the private API you're tying your code to the exact Qt version (i.e. you break the binary compatibility between your library and Qt).

    Kind regards.



  • Thank you for advice.
    I explore existing sources where used private API. And now make by analog. I know about version problem and will try to avoid using private API later.


Log in to reply