QT Creator .ui in .pri

  • In a qt application, for a more correct organization ,
    I have grouped "source", "header" and "ui" into some .pri files.
    I noticed that I can not use the objects ui included in
    .pri if I do not first rebuild, unlike those in .pro.

    PS: the files are all in the same directory.

    Some idea???

    Excuse for my easy english

  • @gmires

    Hi and welcome to devnet forum

    You can use also the FORMS variable in a .pri file. You include the .pri file in your .pro file?

    What operation system are you on ?

  • Thanks first of all,
    I included the .pri ne .pro file.
    in .pri I have the HEADERS, SOURCES, AND FORMS variables ..
    If I change the name of an object on forms that are included in .pri if I do not rebuild I can not use it in the source.

    As if for forms not included in the .pri qt creator, I proposed the names of the objects in the .ui file instead of the ones contained in the header created by "uic.exe".


  • @gmires

    I have simply created a fresh GUI application with creator. Here is the modified .pro:

    # Project created by QtCreator 2017-10-10T16:44:34
    QT       += core gui
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    TARGET = untitled
    TEMPLATE = app
    # The following define makes your compiler emit warnings if you use
    # any feature of Qt which has been marked as deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    # You can also make your code fail to compile if you use deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    #SOURCES += \
    #        main.cpp \
    #        mainwindow.cpp
    #HEADERS += \
    #        mainwindow.h
    #FORMS += \
    #        mainwindow.ui

    and here is the .pri file, which is actually a simple copy of .pro and the duplicated lines are deleted.

    # Project created by QtCreator 2017-10-10T16:44:34
    SOURCES += \
            main.cpp \
    HEADERS += \
    FORMS += \

    You might have to be careful, if you bring the .pri file to another folder. Then you need to care of the folder change as well. Also you need to use the continuation character (backslash) for adding new lines.

    And this is how it should look in the project pane of Qt creator

    [edit: koahnig] Just in case do also a rerun of qmake and a rebuild in Qt creator.

  • Is what I did practically,
    I attach you a photo..
    in fact everything works correctly, it only seems strange that if I modify the form that is not included in the .pri I can use the objects without rebuilding qmake or rebuild, if instead modifying those included, if qmake and rebuild do not find them in ui-> on the source.

    FILE .pro

    # Project created by QtCreator 2017-05-24T15:00:59
    QT       += core gui sql network
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    TARGET = orisplayer
    TEMPLATE = app
    SOURCES += main.cpp\
            mainwindow.cpp \
        db_record.cpp \
        db_manager.cpp \
        db_tb_configure.cpp \
        mainconfigura.cpp \
        configura01.cpp \
        configura02.cpp \
        configura03.cpp \
        configura04.cpp \
        configura04_item.cpp \
        attesa.cpp \
        db_tb_campane.cpp \
        configura05_ore01.cpp \
        configura05_ore02.cpp \
        configura06_save.cpp \
        conferma.cpp \
        configura_loc.cpp \
        db_config.cpp \
        utility.cpp \
        configura_lan.cpp \
    HEADERS  += mainwindow.h \
        defines.h \
        db_record.h \
        db_manager.h \
        db_tb_configure.h \
        mainconfigura.h \
        configura01.h \
        configura02.h \
        ipage.h \
        configura03.h \
        configura04.h \
        configura04_item.h \
        attesa.h \
        db_tb_campane.h \
        configura05_ore01.h \
        configura05_ore02.h \
        configura06_save.h \
        conferma.h \
        configura_loc.h \
        db_config.h \
        utility.h \
        configura_lan.h \
    FORMS    += mainwindow.ui \
        mainconfigura.ui \
        configura01.ui \
        configura02.ui \
        configura03.ui \
        configura04.ui \
        configura04_item.ui \
        attesa.ui \
        configura05_ore01.ui \
        configura05_ore02.ui \
        configura06_save.ui \
        conferma.ui \
        configura_loc.ui \
        configura_lan.ui \
    target.path = /root/APP
    INSTALLS += target
    RESOURCES += \
    unix:!macx: LIBS += -L$$PWD/../../qxwidget-project/build-qxwidgets-DVM28-Release/ -lqxwidgets
    INCLUDEPATH += $$PWD/../../qxwidget-project/qxwidgets
    DEPENDPATH += $$PWD/../../qxwidget-project/qxwidgets
    unix:!macx: PRE_TARGETDEPS += $$PWD/../../qxwidget-project/build-qxwidgets-DVM28-Release/libqxwidgets.a

    FILE .pri

    HEADERS += keyboard.h \
    	pinpad.h \ 
    SOURCES += keyboard.cpp \
    	pinpad.cpp \
    FORMS += pinpad.ui \

  • @gmires said in QT Creator .ui in .pri:

    in fact everything works correctly, it only seems strange that if I modify the form that is not included in the .pri I can use the objects without rebuilding qmake or rebuild, if instead modifying those included, if qmake and rebuild do not find them in ui-> on the source.

    Oh, you mean the autocompletion in Qt creator while referencing new objects or modified objects which are part of the pinpad.ui and/or datetimepad.ui in your case?

  • I attach you a photo
    operating system : Ubutnu x64 17.04


  • @koahnig
    yes just this,
    did not cause malfunctions, but it was just to understand.


  • @gmires

    I have seen similar or the same behaviour on win 10 64 bit with creator. .pro file does not hold any source, header or ui and therefore, it is a sort of standard behaviour I have seen. Probably it is a bug then judging from what you have noticed.

    You can check on JIRA, if there is already a bug report filed and file one, if not.

  • @gmires is it me but I cannot see where in your .pro file you actually include your .pri file? As explained here for instance.

  • @Pablo-J.-Rogina

    It is


    Further down in file.pro. His reference to File.pri is actually not correct, but you can see from the screenshot given later.

  • @Pablo-J-Rogina , @koahnig

    I tried to include the .pri file in various parts of .pro to see if it could depend on it

Log in to reply

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