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 create .CPP class for a Form?
Forum Updated to NodeBB v4.3 + New Features

How to create .CPP class for a Form?

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 4 Posters 2.8k Views 3 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by SGaist
    #2

    Hi and welcome to devnet,

    Add UIC += test.ui to your .pro file.

    Add FORMS += test.ui to your .pro file.

    Did you only create the .ui file or did you ask for a widget to be used with designer ? If the later, you should already have everything needed in your .pro file.

    [edit: fixed qmake variable name SGaist]

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    aha_1980A 1 Reply Last reply
    2
    • SGaistS SGaist

      Hi and welcome to devnet,

      Add UIC += test.ui to your .pro file.

      Add FORMS += test.ui to your .pro file.

      Did you only create the .ui file or did you ask for a widget to be used with designer ? If the later, you should already have everything needed in your .pro file.

      [edit: fixed qmake variable name SGaist]

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #3

      @SGaist shouldn't that be FORMS += test.ui?

      Qt has to stay free or it will die.

      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        @aha_1980 Yes, you're correct ! Looking at cmake stuff and got it mixed :)

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        2
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #5

          Hi
          I wonder if u choose the wrong template to begin with ?
          alt text

          That one create both .h and .cpp and UI file.

          The one next in list, creates ONLY the UI file.

          1 Reply Last reply
          1
          • SprezzaturaS Offline
            SprezzaturaS Offline
            Sprezzatura
            wrote on last edited by
            #6

            @SGaist My .PRO file does contain FORMS += test.ui

            @mrjj Yes I do believe I chose "Qt Designer Form" (instead of "Qt Designer Form Class")

            I will try the "Class" version.

            Thank you.

            1 Reply Last reply
            0
            • SprezzaturaS Offline
              SprezzaturaS Offline
              Sprezzatura
              wrote on last edited by
              #7

              Yes, that was the problem. The solution is to choose "Qt Designer Form Class".

              I will be writing a utility to convert 300 Win32 Resource dialogs to Qt. I looked at KNUT: by the time I figure out how to compile and run it, I can write the conversion program. Plus, KNUT uses the .EXE, I have an .RC file.

              mrjjM 1 Reply Last reply
              0
              • SprezzaturaS Sprezzatura

                Yes, that was the problem. The solution is to choose "Qt Designer Form Class".

                I will be writing a utility to convert 300 Win32 Resource dialogs to Qt. I looked at KNUT: by the time I figure out how to compile and run it, I can write the conversion program. Plus, KNUT uses the .EXE, I have an .RC file.

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #8

                @Sprezzatura
                Holy mother of old code. 30 300 dialogs in one program?
                What is knut ? Do you have a link to it ?

                Note that Qts UI files are XML and could be produced from
                external application.

                1 Reply Last reply
                1
                • SprezzaturaS Offline
                  SprezzaturaS Offline
                  Sprezzatura
                  wrote on last edited by Sprezzatura
                  #9

                  That's three hundred dialogs, not thirty (includes multi-page Property Sheets) :o)

                  KNUT used to be offered by KDAB, the Qt consulting company. It is no longer mentioned on their site.

                  You can get the source code for KNUT from here:

                  https://www.opendesktop.org/c/1466642231

                  I can see how Qt .UI files are structured. It will be fairly straightforward to convert a Visual Studio .RC to XML. I can even automatically generate the class .CPP and .H files.

                  mrjjM 1 Reply Last reply
                  1
                  • SprezzaturaS Sprezzatura

                    That's three hundred dialogs, not thirty (includes multi-page Property Sheets) :o)

                    KNUT used to be offered by KDAB, the Qt consulting company. It is no longer mentioned on their site.

                    You can get the source code for KNUT from here:

                    https://www.opendesktop.org/c/1466642231

                    I can see how Qt .UI files are structured. It will be fairly straightforward to convert a Visual Studio .RC to XML. I can even automatically generate the class .CPP and .H files.

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    @Sprezzatura
                    Yes, typo :) Thats massive.
                    Ah, that is old :) Qt3 code will need changes to compile
                    on 5.11. But interesting never the less.

                    Just as a note in case you missed it
                    http://doc.qt.io/qt-5/uic.html
                    Qt dont actually use the UI at runtime. its already converted to c++ code.

                    1 Reply Last reply
                    1
                    • SprezzaturaS Offline
                      SprezzaturaS Offline
                      Sprezzatura
                      wrote on last edited by
                      #11

                      @mrjj and @SGaist Thanks very much for your help. My "RCtoUI" conversion program is starting to produce results. It's great to open up a .UI file with Qt Creator and magically see the dialog appear. It looks like I have to multiply the VS RC dialog units by 2 to get them to scale and look OK in Qt.

                      I will provide a link to download the RCtoUI executable (when it's completed) if anyone is interested.

                      mrjjM 1 Reply Last reply
                      3
                      • SprezzaturaS Sprezzatura

                        @mrjj and @SGaist Thanks very much for your help. My "RCtoUI" conversion program is starting to produce results. It's great to open up a .UI file with Qt Creator and magically see the dialog appear. It looks like I have to multiply the VS RC dialog units by 2 to get them to scale and look OK in Qt.

                        I will provide a link to download the RCtoUI executable (when it's completed) if anyone is interested.

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #12

                        @Sprezzatura
                        Im pretty sure anyone faced with the task of converting old win32
                        dialog code to Qt would find RCtoUI very useful so please do
                        And congrats with the progress :)

                        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