Qt World Summit: Submit your Presentation

Using individual ui files

  • Hi,
    I created a ui file using Qt Creator. I would like to use it to display labels. How can I use it from an existing class? I checked the examples available online but unfortunately none of the worked.
    Thank you.

  • @gabor53

    Depends on your intensions. Possibly this is helping

  • @koahnig
    Unfortunately this didn't help as it is about custom widgets.

  • Created a ui named display.ui using File ->New File in Creator.
    The pro file section looks like this:

    FORMS    += \
        additem.ui \
        review.ui \
        mainwindow.ui \
        imagedisplay.ui \

    and the header of the file mainwindow.cpp where I want to use the form looks like this:

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include "ui_display.h"
    #include <imagedisplay.h>

    When I try to use display.ui from mainwindow.h I use:


    but in the dropdown display.ui is not listed. What am I missing? Thank you.

  • Hi,
    I usually use one ui-file with one cpp-file and one header-file, like:
    display.h there use ui::DisplayClass or what the name is
    mainwindow.h there use ui::MainWindowClass or what the name is
    I would not try to mix-up the two classes Display and MainWindow.

  • @m.sue
    Thank you.

Log in to reply