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. My first Qt widgets app

My first Qt widgets app

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 428 Views 1 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.
  • C Offline
    C Offline
    Circuits
    wrote on last edited by
    #1

    Hello, so I have a bit of experience with Qt but very little (never used the designer). I just recently started a hello world widgets app and after double clicking the mainwindow.ui file it brought up the designer. I was able to drag and drop a label and everything worked fine. However, when I went to browse the code for that label, I was supersized when I did not find it in main.cpp. In fact, I can't seem to find it anywhere. Apparently creating a label with the designer is not the same thing as creating a label like this:

    QLabel label;
    

    I figured the designer was auto generating code, where is that code? Please help me understand what it is exactly that I do not understand XD

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      You could read https://doc.qt.io/qt-5/qtdesigner-manual.html

      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
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by SGaist
        #3

        Hi and welcome to devnet,

        Designer generates a .ui file which contains an XML description of your widget.

        The you have the uic tool that is going to generate the code needs for your widget to be setup. You'll end up with 3 files:

        • The .uic that you keep in your sources
        • The code generate from the .uic file that you don't keep in your sources
        • The code of the widget that will use what was generated plus what you write in it for the logic. File that you keep.

        For more information see the Qt Creator documentation about the widget designer and the designer documentation itself.

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

        C 1 Reply Last reply
        2
        • SGaistS SGaist

          Hi and welcome to devnet,

          Designer generates a .ui file which contains an XML description of your widget.

          The you have the uic tool that is going to generate the code needs for your widget to be setup. You'll end up with 3 files:

          • The .uic that you keep in your sources
          • The code generate from the .uic file that you don't keep in your sources
          • The code of the widget that will use what was generated plus what you write in it for the logic. File that you keep.

          For more information see the Qt Creator documentation about the widget designer and the designer documentation itself.

          C Offline
          C Offline
          Circuits
          wrote on last edited by
          #4

          @SGaist Awesome, thanks, I missed the text for the label because I figured it would be created in the main.cpp and surrounded with double quotes but I found it in the .ui file:

          <string>This is the label text</string>
          

          So would you suggest using designer for a larger application? Are there limitations to the designer that I should be aware of? I will go through the documentation but what do you think, in general, about the designer?

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

            It frankly depends on your taste.

            I personally always code everything by hand but it's a matter of habit. Do what you find best for your development process.

            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

            • Login

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