Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to generate .h and .cpp from .ui???
Forum Updated to NodeBB v4.3 + New Features

How to generate .h and .cpp from .ui???

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 7 Posters 16.9k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    squirrlmcbuttcheeks
    wrote on 29 Aug 2016, 21:50 last edited by squirrlmcbuttcheeks
    #1

    used to be able to generate both .h and .cpp from uic...

    HOW do I do this now...
    I have a .ui file from qt designer, I need the cpp and .h files.

    I do NOT want to run qt creator, it crashes.
    I want the command line which I need to run, giving it the UI file and ending up with
    a cpp, a .h along with the .ui
    From a windows command prompt (cmd.exe)

    R 1 Reply Last reply 31 Aug 2016, 01:08
    0
    • C Offline
      C Offline
      Charlie_Hdz
      wrote on 29 Aug 2016, 22:21 last edited by
      #2

      Hi @squirrlmcbuttcheeks.

      A Ui file is a XML file.

      A UI File can also run as an embedded application inside other IDEs (Eclipse and VIsual Studio).

      The UI files are translated to .cpp and .h files by the User Interface Compiler (uic).

      This is only what I know, I hope it works for you.

      Carlos Hdz.

      Kind Regards,
      Enrique Hernandez
      gearstech.com.mx
      chernandez@gearstech.com.mx

      1 Reply Last reply
      0
      • S Offline
        S Offline
        squirrlmcbuttcheeks
        wrote on 29 Aug 2016, 22:49 last edited by
        #3

        You used to be able to do this:
        uic -i PizzaEntry.h -o PizzaEntry.cpp pizza.ui

        and it would generate the PizzaEntry.cpp file, but the -i option is now missing...

        Anyone have any ideas?

        Anyone know which uic version had it last? I'll try to find that and stick with the old version if theres
        no new way to generate the cpp files

        V 1 Reply Last reply 31 Aug 2016, 08:18
        1
        • J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 30 Aug 2016, 04:37 last edited by
          #4

          uic now generates only a header file containing all methods as inline (inside the class) methods. There is no need for a cpp file.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          3
          • S squirrlmcbuttcheeks
            29 Aug 2016, 21:50

            used to be able to generate both .h and .cpp from uic...

            HOW do I do this now...
            I have a .ui file from qt designer, I need the cpp and .h files.

            I do NOT want to run qt creator, it crashes.
            I want the command line which I need to run, giving it the UI file and ending up with
            a cpp, a .h along with the .ui
            From a windows command prompt (cmd.exe)

            R Offline
            R Offline
            Rondog
            wrote on 31 Aug 2016, 01:08 last edited by
            #5

            @squirrlmcbuttcheeks said in How to generate .h and .cpp from .ui???:

            used to be able to generate both .h and .cpp from uic...

            HOW do I do this now...
            I have a .ui file from qt designer, I need the cpp and .h files.

            I do NOT want to run qt creator, it crashes.
            I want the command line which I need to run, giving it the UI file and ending up with
            a cpp, a .h along with the .ui
            From a windows command prompt (cmd.exe)

            One thing I like about Qt is that you can write everything in C++. I don't think I have ever used a UI generated file as intended. I am sure it works and all that but it seems ugly in some aspects (which is not really a good reason) so I have never used it.

            There is a downside of creating classes in C++ (source + header). You tend to add in additional functionallity to the generated code which becomes a problem if you want to use the Qt Designer to 'edit' the class. This works fine if you are willing to adjust the GUI without using the Qt Designer but it is a bit harder to do.

            My preference is to convert the UI files directly to cpp/h source files and live with the downsides of doing this. If the new version has changed what the generated code looks like you can either use an older version of UIC or write something to convert the XML UI file into the source code you would like to see.

            1 Reply Last reply
            0
            • S squirrlmcbuttcheeks
              29 Aug 2016, 22:49

              You used to be able to do this:
              uic -i PizzaEntry.h -o PizzaEntry.cpp pizza.ui

              and it would generate the PizzaEntry.cpp file, but the -i option is now missing...

              Anyone have any ideas?

              Anyone know which uic version had it last? I'll try to find that and stick with the old version if theres
              no new way to generate the cpp files

              V Offline
              V Offline
              VRonin
              wrote on 31 Aug 2016, 08:18 last edited by
              #6

              @squirrlmcbuttcheeks

              uic -o PizzaEntry.h
              

              This will generate the inline header for the UI, no more .cpp file. if you want to move implementation to source file you are free to do it manually afterwards

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              1 Reply Last reply
              0
              • G Offline
                G Offline
                Giakara
                wrote on 1 Jul 2021, 09:02 last edited by
                #7

                Hello did you find a way to translate into cpp hpp with old uic?

                C 1 Reply Last reply 1 Jul 2021, 09:08
                0
                • G Giakara
                  1 Jul 2021, 09:02

                  Hello did you find a way to translate into cpp hpp with old uic?

                  C Offline
                  C Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on 1 Jul 2021, 09:08 last edited by
                  #8

                  @Giakara said in How to generate .h and .cpp from .ui???:

                  Hello did you find a way to translate into cpp hpp with old uic?

                  @VRonin said

                  If you want to move implementation to source file you are free to do it manually afterwards

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved