Merge QDialog project into a QWindow project

  • I have two separate projects, one is a QDialog and another is a QWindow.

    I would like to integrate the QDialog into the QWindow project.

    My QDialog .pro file contains this:

    QT += core gui
    QT += serialport
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    CONFIG += c++11
    # You can make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    SOURCES += \
        main.cpp \
    HEADERS += \
        dialog.h \
    FORMS += \
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target

    I won't copy the file because is very long, but can tell you that:

    • It doesn't contain the QT += core gui QT += serialport lines that the QDialog has
    • It doesn't contain any Forms

    How can merge the QDialog into the QWindow project?

  • Lifetime Qt Champion

    You can just add

    To your QWindow project and simply
    create an instance of the dialog and show it.

    Copy the files first to the QWindow project folder
    then right click in Creator and use the Add existing files.
    Then select the files.
    alt text

    Since dialog project use
    QT += serialport

    you might want to add that to the project file if it does need qserialport class.

  • This worked.


Log in to reply