Important: Please read the Qt Code of Conduct -

QFile, QDir, QXmlStreamWriter and other classes from QtCore in plain C++ project.

  • Hi,

    It is possible to use classes from QtCore, especially QFile, QFileInfo, QDir, QXmlStreamWritter, QXmlStreamReader, QMimeDatabase, QMimeType and some other in plain c++ project without any problems?

    Then i only need QtCore5.dll, i am right?

  • Lifetime Qt Champion

    In theory yes.
    But you might need platforms plugin too.

    Should be fast to test.

  • Ok, but what with signals and slots?

    When some Qt classes from QtCore emit signal, and in my project I do not have QApplication instance, it will not be a problem?

  • Lifetime Qt Champion

    Yes it will. you need to supply event loop for signals to work.

    I think Qt::DirectConnection might work without event loop.

    Can I ask why you want to use Qt and then not?
    You could get nice file handling with pure c++and
    xml with pugixml and have no dlls what so ever.

  • I prefer Qt classes for filesystem / xml because I already have some code which use this classes but in Qt project.

    I can use boost for filesystem / xml ( propertytree? ), but then I also need dll but from boost so it nothing changes.

    "You could get nice file handling with pure c++"
    I think that this is not possible ;)

  • Lifetime Qt Champion

    Ok. but why not just use it ?
    and not worry if 1 or 2 dlls?
    But yes, if you cut back on what class you use,
    you should be able to cut some of the DLLS too.

    C++ io not so bad. (IMHO) :)

            list data;
            string line;       
            ifstream myfile ("test.txt");
            if (myfile.is_open())    {
                for(line; getline(myfile, line);){

  • It is more complicated ;)

    One example - detect mime type for file?
    And many more which using Qt is simple but without Qt can take much more time.

    I ask because sometimes simple task can works but later when i writed more code i can make troubles and then it will horrible.
    Maybe someone know about problems using QtCore in plain c++ project. Only that ;)

    I do not worry about dlls, but i do not want segfault or crash when i run my application which using some Qt classes in plain c++ project.

  • Lifetime Qt Champion

    Ok. I see your point.
    Well I don't think you can really get in trouble using only core.
    But with no default event loop, you might get a few surprises. :)
    Good luck

  • "But with no default event loop, you might get a few surprises"

    Oh you know somethink more? ;) Please tell me ;)
    I will have a trouble even if i do not connect signals?

  • Lifetime Qt Champion

    No No :) It's just that Qt uses signals
    all over so some functions might use a signal to inform you of something or
    two Qt objects might use signal internally.

    But currently I made a small console project using QFile and to my surprise
    it ask for no DLL when i click it, so i'm a bit ??:)

  • Lifetime Qt Champion

    I must do something wrong as for console app with Qfile it wants
    (win 7 , mingw compiler)
    on a clean machine (virtual)
    Not as tiny as i had hoped for :)

Log in to reply