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. Why does the ui_xxx.h include other custom-written header files?

Why does the ui_xxx.h include other custom-written header files?

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 3.2k 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.
  • Z Offline
    Z Offline
    zxw2006063
    wrote on last edited by
    #1

    Hi,

    I was trying to understand a qt project developed by others. I am told that the ui_xxx.h is automatically converted from the .ui file with the help of qmake. But why I found two other custom-written header files are included in the ui-xxx.h? So what is that? I am a entry level learner. Any replies will be appreciated.

    Regards

    Xzhou

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

      Hi and welcome to devnet,

      Without more information, I would say that the others that have written the code did something wrong.

      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
      0
      • M Offline
        M Offline
        MuldeR
        wrote on last edited by
        #3

        Well, the "UIC":http://qt-project.org/doc/qt-4.8/uic.html tool provided by Qt is used to generate header files (.h) from the ".ui" files. You are not supposed to edit those UIC-generated header files, because it will be overwritten the next time UIC is run. Anyway, we don't know whether your "ui-xxx.h" was really generated by UIC or is something else. If a file really was generated by UIC, its should start like this:

        @** Form generated from reading UI file 'AboutDialog.ui'
        **
        ** Created by: Qt User Interface Compiler version 4.8.6
        **
        ** WARNING! All changes made in this file will be lost when recompiling UI file!@

        If your "ui-xxx.h" file indeed does start like this, then it should not contain any "custom" code and it should not include any "custom" header files. Still, somebody might have done something silly! Who knows ;-)

        My OpenSource software at: http://muldersoft.com/

        Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

        Go visit the coop: http://youtu.be/Jay...

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andreyc
          wrote on last edited by
          #4

          Or they "promoted":http://qt-project.org/doc/qt-5/designer-using-custom-widgets.html#promoting-widgets a generic widget to a custom widget.

          In this case uic will include custom header files of the custom widgets in ui_xxxx.h file of the main widget.

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            zxw2006063
            wrote on last edited by
            #5

            Hi,
            The ui_xxx.h file in my case starts with these:
            @
            /
            *******************************************************************************
            ** Form generated from reading UI file 'texo.ui'
            **
            ** Created by: Qt User Interface Compiler version 4.8.5
            **
            ** WARNING! All changes made in this file will be lost when recompiling UI file!
            ********************************************************************************/

            #ifndef UI_TEXO_H
            #define UI_TEXO_H

            #include <QtCore/QVariant>
            #include <QtGui/QAction>
            #include <QtGui/QApplication>
            #include <QtGui/QButtonGroup>
            #include <QtGui/QComboBox>
            #include <QtGui/QGridLayout>
            #include <QtGui/QGroupBox>
            #include <QtGui/QHBoxLayout>
            #include <QtGui/QHeaderView>
            #include <QtGui/QLabel>
            #include <QtGui/QMainWindow>
            #include <QtGui/QMenu>
            #include <QtGui/QMenuBar>
            #include <QtGui/QPushButton>
            #include <QtGui/QSlider>
            #include <QtGui/QSpacerItem>
            #include <QtGui/QStatusBar>
            #include <QtGui/QTableWidget>
            #include <QtGui/QToolBar>
            #include <QtGui/QVBoxLayout>
            #include <QtGui/QWidget>
            #include "TexoView.h"
            #include "TexoViewImg.h"
            @

            The TexoView.h and TexoViewImg.h are two header files included in the ui_xxx.h file. And I can find the TexiView.h and TexoViewImg.h in the directory of the project file. So could you tell me why? I am sure the project works well.

            Many thanks.

            [quote author="MuldeR" date="1410390576"]Well, the "UIC":http://qt-project.org/doc/qt-4.8/uic.html tool provided by Qt is used to generate header files (.h) from the ".ui" files. You are not supposed to edit those UIC-generated header files, because it will be overwritten the next time UIC is run. Anyway, we don't know whether your "ui-xxx.h" was really generated by UIC or is something else. If a file really was generated by UIC, its should start like this:

            @** Form generated from reading UI file 'AboutDialog.ui'
            **
            ** Created by: Qt User Interface Compiler version 4.8.6
            **
            ** WARNING! All changes made in this file will be lost when recompiling UI file!@

            If your "ui-xxx.h" file indeed does start like this, then it should not contain any "custom" code and it should not include any "custom" header files. Still, somebody might have done something silly! Who knows ;-)[/quote]

            [andreyc EDIT]: Added @ around code.

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              zxw2006063
              wrote on last edited by
              #6

              Hi,

              Can you tell me more details about this? Or can you give me some sources where I can look up? Thank you so much.

              The ui_xxx.h file definitely is generated by .ui file. And the included custom-written header files can been found in the project.

              [quote author="andreyc" date="1410390887"]Or they "promoted":http://qt-project.org/doc/qt-5/designer-using-custom-widgets.html#promoting-widgets a generic widget to a custom widget.

              In this case uic will include custom header files of the custom widgets in ui_xxxx.h file of the main widget.[/quote]

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andreyc
                wrote on last edited by
                #7

                Open texo.ui in a designer. Right click anywhere on a form.
                Click on "Promoted widgets" in the context menu.
                You should see a dialog with a list of promoted widgets.
                It should include TexoView and TexoViewImg classes with their header files.

                If these lines do not exist then there is something wrong with the project.

                1 Reply Last reply
                0
                • Z Offline
                  Z Offline
                  zxw2006063
                  wrote on last edited by
                  #8

                  They do exist in the list of promoted widgets. Thanks for this.

                  [quote author="andreyc" date="1410471126"]Open texo.ui in a designer. Right click anywhere on a form.
                  Click on "Promoted widgets" in the context menu.
                  You should see a dialog with a list of promoted widgets.
                  It should include TexoView and TexoViewImg classes with their header files.

                  If these lines do not exists then there is something wrong with the project.[/quote]

                  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