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. what is use of forward declaration " Ui::MainWindow *ui; " in qt ?

what is use of forward declaration " Ui::MainWindow *ui; " in qt ?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 1.8k Views
  • 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.
  • Q Offline
    Q Offline
    Qt embedded developer
    wrote on last edited by
    #1

    I want to know reason behind use of Ui::MainWindow *ui; in header file

    jsulmJ 1 Reply Last reply
    0
    • Q Qt embedded developer

      I want to know reason behind use of Ui::MainWindow *ui; in header file

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Qt-embedded-developer Explained in documentation: https://doc.qt.io/qt-5/designer-using-a-ui-file.html

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

      Q 1 Reply Last reply
      2
      • jsulmJ jsulm

        @Qt-embedded-developer Explained in documentation: https://doc.qt.io/qt-5/designer-using-a-ui-file.html

        Q Offline
        Q Offline
        Qt embedded developer
        wrote on last edited by Qt embedded developer
        #3

        @jsulm means its use for 2 purpose
        1] provides the code for setting up and managing the user interface.
        2] the form can then be changed without recompiling the dependent source files

        JonBJ 1 Reply Last reply
        0
        • Q Qt embedded developer

          @jsulm means its use for 2 purpose
          1] provides the code for setting up and managing the user interface.
          2] the form can then be changed without recompiling the dependent source files

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Qt-embedded-developer
          It means what it says there:

          Using a Pointer Member Variable

          Alternatively, the Ui::CalculatorForm structure can be made a pointer member of the class

          The advantage of this approach is that the user interface object can be forward-declared, which means that we do not have to include the generated ui_calculatorform.h file in the header. The form can then be changed without recompiling the dependent source files.

          When you declare Ui::MainWindow *ui; (a pointer) in a header file, if the definition of Ui::MainWindow changes (e.g. widgets added) you do not have to recompile modules which include just the pointer declaration, rather than the class it points to. C++ stuff.

          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