Qt World Summit: Register Today!

Calling the functions of Qt from the C++ files

  • I have my own C++ file random.cc that includes files

    @#include <QMainWindow>
    #include <QApplication>@

    I build my C++ file as

    @g++ random.cc mainwindow.cpp -I ../qt/5.3/gcc_64/include/QtWidgets/ -I ../qt/5.3/gcc_64/include -fPIC@

    However, it throws the following error:

    @mainwindow.cpp:2:27: fatal error: ui_mainwindow.h: No such file or directory
    #include "ui_mainwindow.h"@

    Is there a way to prebuild the file ui_mainwindow.h.?

  • Qt Champions 2017

    This is path issue. Compilation is not able to find the ui_main* files. You can use uic tool generate the ui_main*.h files and keep it where you require. Or you can use UI_DIR directive in pro file to keep you ui_main*.h into specific directory.

  • Can you show your *.pro file
    and what IDE you are using?

Log in to reply