Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. UIC doesn’t use the object name to create UI_MyClass.h
Forum Updated to NodeBB v4.3 + New Features

UIC doesn’t use the object name to create UI_MyClass.h

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
13 Posts 2 Posters 953 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.
  • CP71C Offline
    CP71C Offline
    CP71
    wrote on last edited by
    #1

    Hi all,
    I am using QtCreator 12.0.1 with Qt kit 4.8.7 (32 bit) on Linux 64 bit.
    I am seeing some strange behaviour on UI files, in UI_MyClass .h the pointers to objects don’t use the objectName to naming the variables.

    So, if I have a pushButton named “pushButtonMy” (see formtest.ui), in UI_MyClass.h I see a pointer named “pushButton” (see ui_formtest.h) and I don’t know why.

    In formtest.ui

    <?xml version="1.0" encoding="UTF-8"?>
    <ui version="4.0">
     <class>FormTest</class>
     <widget class="QWidget" name="FormTest">
      <property name="geometry">
       <rect>
        <x>0</x>
        <y>0</y>
        <width>400</width>
        <height>300</height>
       </rect>
      </property>
      <property name="windowTitle">
       <string>Form</string>
      </property>
      <widget class="QPushButton" name="pushButtonMy">
       <property name="geometry">
        <rect>
         <x>10</x>
         <y>10</y>
         <width>92</width>
         <height>30</height>
        </rect>
       </property>
       <property name="text">
        <string>PushButton</string>
       </property>
      </widget>
     </widget>
     <resources/>
     <connections/>
    </ui>
    

    in ui_formtest.h

    /********************************************************************************
    ** Form generated from reading UI file 'formtest.ui'
    **
    ** Created by: Qt User Interface Compiler version 4.8.7
    **
    ** WARNING! All changes made in this file will be lost when recompiling UI file!
    ********************************************************************************/
    
    #ifndef UI_FORMTEST_H
    #define UI_FORMTEST_H
    
    #include <QtCore/QVariant>
    #include <QtGui/QAction>
    #include <QtGui/QApplication>
    #include <QtGui/QButtonGroup>
    #include <QtGui/QHeaderView>
    #include <QtGui/QPushButton>
    #include <QtGui/QWidget>
    
    QT_BEGIN_NAMESPACE
    
    class Ui_FormTest
    {
    public:
        QPushButton *pushButton;
    
        void setupUi(QWidget *widget)
        {
            if (widget->objectName().isEmpty())
                widget->setObjectName(QString::fromUtf8("widget"));
            widget->resize(400, 300);
            pushButton = new QPushButton(widget);
            pushButton->setObjectName(QString::fromUtf8("pushButton"));
            pushButton->setGeometry(QRect(10, 10, 92, 30));
    
            retranslateUi(widget);
    
            QMetaObject::connectSlotsByName(widget);
        } // setupUi
    
        void retranslateUi(QWidget *widget)
        {
            widget->setWindowTitle(QApplication::translate("FormTest", "Form", 0, QApplication::UnicodeUTF8));
            pushButton->setText(QApplication::translate("FormTest", "PushButton", 0, QApplication::UnicodeUTF8));
        } // retranslateUi
    
    };
    
    namespace Ui {
        class FormTest: public Ui_FormTest {};
    } // namespace Ui
    
    QT_END_NAMESPACE
    
    #endif // UI_FORMTEST_H
    

    thanks in advance
    CP71

    Christian EhrlicherC 1 Reply Last reply
    0
    • CP71C CP71

      @Christian-Ehrlicher
      Excuse my English :(, but I believe I didn't understand the purpose of this sentence..
      Do you think this configuration is a problem?

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #10

      If you want a ui file which works with uic from Qt4 you must use a designer from Qt4 and not one from Qt5 or Qt6 as they produce a xml file which can not be properly parsed with the ancient Qt4 uic. I already told you this in my first post here.

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

      CP71C 1 Reply Last reply
      2
      • CP71C CP71

        Hi all,
        I am using QtCreator 12.0.1 with Qt kit 4.8.7 (32 bit) on Linux 64 bit.
        I am seeing some strange behaviour on UI files, in UI_MyClass .h the pointers to objects don’t use the objectName to naming the variables.

        So, if I have a pushButton named “pushButtonMy” (see formtest.ui), in UI_MyClass.h I see a pointer named “pushButton” (see ui_formtest.h) and I don’t know why.

        In formtest.ui

        <?xml version="1.0" encoding="UTF-8"?>
        <ui version="4.0">
         <class>FormTest</class>
         <widget class="QWidget" name="FormTest">
          <property name="geometry">
           <rect>
            <x>0</x>
            <y>0</y>
            <width>400</width>
            <height>300</height>
           </rect>
          </property>
          <property name="windowTitle">
           <string>Form</string>
          </property>
          <widget class="QPushButton" name="pushButtonMy">
           <property name="geometry">
            <rect>
             <x>10</x>
             <y>10</y>
             <width>92</width>
             <height>30</height>
            </rect>
           </property>
           <property name="text">
            <string>PushButton</string>
           </property>
          </widget>
         </widget>
         <resources/>
         <connections/>
        </ui>
        

        in ui_formtest.h

        /********************************************************************************
        ** Form generated from reading UI file 'formtest.ui'
        **
        ** Created by: Qt User Interface Compiler version 4.8.7
        **
        ** WARNING! All changes made in this file will be lost when recompiling UI file!
        ********************************************************************************/
        
        #ifndef UI_FORMTEST_H
        #define UI_FORMTEST_H
        
        #include <QtCore/QVariant>
        #include <QtGui/QAction>
        #include <QtGui/QApplication>
        #include <QtGui/QButtonGroup>
        #include <QtGui/QHeaderView>
        #include <QtGui/QPushButton>
        #include <QtGui/QWidget>
        
        QT_BEGIN_NAMESPACE
        
        class Ui_FormTest
        {
        public:
            QPushButton *pushButton;
        
            void setupUi(QWidget *widget)
            {
                if (widget->objectName().isEmpty())
                    widget->setObjectName(QString::fromUtf8("widget"));
                widget->resize(400, 300);
                pushButton = new QPushButton(widget);
                pushButton->setObjectName(QString::fromUtf8("pushButton"));
                pushButton->setGeometry(QRect(10, 10, 92, 30));
        
                retranslateUi(widget);
        
                QMetaObject::connectSlotsByName(widget);
            } // setupUi
        
            void retranslateUi(QWidget *widget)
            {
                widget->setWindowTitle(QApplication::translate("FormTest", "Form", 0, QApplication::UnicodeUTF8));
                pushButton->setText(QApplication::translate("FormTest", "PushButton", 0, QApplication::UnicodeUTF8));
            } // retranslateUi
        
        };
        
        namespace Ui {
            class FormTest: public Ui_FormTest {};
        } // namespace Ui
        
        QT_END_NAMESPACE
        
        #endif // UI_FORMTEST_H
        

        thanks in advance
        CP71

        Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #2

        I would guess the ui is created with Qt6 designer (inside QtCreator) but uic from Qt4 can't handle this anymore. Create your ui with Qt4 designer and see if the objectName is correctly created.

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

        CP71C 1 Reply Last reply
        1
        • Christian EhrlicherC Christian Ehrlicher

          I would guess the ui is created with Qt6 designer (inside QtCreator) but uic from Qt4 can't handle this anymore. Create your ui with Qt4 designer and see if the objectName is correctly created.

          CP71C Offline
          CP71C Offline
          CP71
          wrote on last edited by
          #3

          @Christian-Ehrlicher
          Hi,
          Thank you so much for your response.
          Yes, I created the user interface in my post using QtCreator 12.0.1 and processed it with UIC 4.8.7.

          But I have encountered this issue on UIs created with Qt 3.2.1 and normally processed by UIC 4.8.7.

          I created the same simple widget in both QtCreator and compared them and they are identical .

          Christian EhrlicherC 1 Reply Last reply
          0
          • CP71C CP71

            @Christian-Ehrlicher
            Hi,
            Thank you so much for your response.
            Yes, I created the user interface in my post using QtCreator 12.0.1 and processed it with UIC 4.8.7.

            But I have encountered this issue on UIs created with Qt 3.2.1 and normally processed by UIC 4.8.7.

            I created the same simple widget in both QtCreator and compared them and they are identical .

            Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by Christian Ehrlicher
            #4

            @CP71 Then uic from Qt4 can't handle object names or has a bug.
            But I think you did something wrong in your test. A ui file from Qt3 sets the name of an object as <property name="name" >... Don't know what Qt4 does though.

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

            CP71C 1 Reply Last reply
            1
            • Christian EhrlicherC Christian Ehrlicher

              @CP71 Then uic from Qt4 can't handle object names or has a bug.
              But I think you did something wrong in your test. A ui file from Qt3 sets the name of an object as <property name="name" >... Don't know what Qt4 does though.

              CP71C Offline
              CP71C Offline
              CP71
              wrote on last edited by
              #5

              @Christian-Ehrlicher

              Then uic from Qt4 can't handle object names or has a bug.
              

              Yeah, at least it looks that way.
              I will try to investigate, if I find the way, I will update you.

              Now I have only one idea:
              I cross compiled the Qt 4.8.7 x86 on my Linux 64 bit, maybe something went wrong, is it possible?
              But I sound it very strange

              But I think you did something wrong in your test. A ui file from Qt3 sets the name of an object as <property name="name" >... Don't know what Qt4 does though.
              

              I think you are right, but I don’t know what is wrong.

              Below you can see the UI created by QtCreator 3.2.1 and normally processed in my VM with Linux 32 and Qt 4.8.7 32 bit.
              But not processed in my Linux 64 bit with Qt 4.8.7 32 bit.

              <?xml version="1.0" encoding="UTF-8"?>
              <ui version="4.0">
               <class>Form</class>
               <widget class="QWidget" name="Form">
                <property name="geometry">
                 <rect>
                  <x>0</x>
                  <y>0</y>
                  <width>200</width>
                  <height>200</height>
                 </rect>
                </property>
                <property name="windowTitle">
                 <string>Form</string>
                </property>
                <widget class="QPushButton" name="pushButtonMy">
                 <property name="geometry">
                  <rect>
                   <x>30</x>
                   <y>20</y>
                   <width>100</width>
                   <height>30</height>
                  </rect>
                 </property>
                 <property name="text">
                  <string>PushButton</string>
                 </property>
                </widget>
               </widget>
               <resources/>
               <connections/>
              </ui>
              

              @Christian-Ehrlicher Thank you very much for your time!

              Christian EhrlicherC 1 Reply Last reply
              0
              • CP71C CP71

                @Christian-Ehrlicher

                Then uic from Qt4 can't handle object names or has a bug.
                

                Yeah, at least it looks that way.
                I will try to investigate, if I find the way, I will update you.

                Now I have only one idea:
                I cross compiled the Qt 4.8.7 x86 on my Linux 64 bit, maybe something went wrong, is it possible?
                But I sound it very strange

                But I think you did something wrong in your test. A ui file from Qt3 sets the name of an object as <property name="name" >... Don't know what Qt4 does though.
                

                I think you are right, but I don’t know what is wrong.

                Below you can see the UI created by QtCreator 3.2.1 and normally processed in my VM with Linux 32 and Qt 4.8.7 32 bit.
                But not processed in my Linux 64 bit with Qt 4.8.7 32 bit.

                <?xml version="1.0" encoding="UTF-8"?>
                <ui version="4.0">
                 <class>Form</class>
                 <widget class="QWidget" name="Form">
                  <property name="geometry">
                   <rect>
                    <x>0</x>
                    <y>0</y>
                    <width>200</width>
                    <height>200</height>
                   </rect>
                  </property>
                  <property name="windowTitle">
                   <string>Form</string>
                  </property>
                  <widget class="QPushButton" name="pushButtonMy">
                   <property name="geometry">
                    <rect>
                     <x>30</x>
                     <y>20</y>
                     <width>100</width>
                     <height>30</height>
                    </rect>
                   </property>
                   <property name="text">
                    <string>PushButton</string>
                   </property>
                  </widget>
                 </widget>
                 <resources/>
                 <connections/>
                </ui>
                

                @Christian-Ehrlicher Thank you very much for your time!

                Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #6

                Are you sure your QtCreator 3.2.1 is built with Qt4?

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

                CP71C 1 Reply Last reply
                0
                • Christian EhrlicherC Christian Ehrlicher

                  Are you sure your QtCreator 3.2.1 is built with Qt4?

                  CP71C Offline
                  CP71C Offline
                  CP71
                  wrote on last edited by
                  #7

                  @Christian-Ehrlicher
                  Yes, I confirm.
                  In my VM I have QtCreator 3.2.1 (Based 5.3.2 GCC 4.9.2) with Qt 4.8.7 32 bit.

                  It works well, I didn't see issues.

                  Only for curiosity, do you see something of strange in this configuration?

                  Christian EhrlicherC 1 Reply Last reply
                  0
                  • CP71C CP71

                    @Christian-Ehrlicher
                    Yes, I confirm.
                    In my VM I have QtCreator 3.2.1 (Based 5.3.2 GCC 4.9.2) with Qt 4.8.7 32 bit.

                    It works well, I didn't see issues.

                    Only for curiosity, do you see something of strange in this configuration?

                    Christian EhrlicherC Offline
                    Christian EhrlicherC Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #8

                    @CP71 You show clearly that QtCreator is built with Qt5. Create your ui files with a Qt4 based designer.

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

                    CP71C 1 Reply Last reply
                    1
                    • Christian EhrlicherC Christian Ehrlicher

                      @CP71 You show clearly that QtCreator is built with Qt5. Create your ui files with a Qt4 based designer.

                      CP71C Offline
                      CP71C Offline
                      CP71
                      wrote on last edited by
                      #9

                      @Christian-Ehrlicher
                      Excuse my English :(, but I believe I didn't understand the purpose of this sentence..
                      Do you think this configuration is a problem?

                      Christian EhrlicherC 1 Reply Last reply
                      0
                      • CP71C CP71

                        @Christian-Ehrlicher
                        Excuse my English :(, but I believe I didn't understand the purpose of this sentence..
                        Do you think this configuration is a problem?

                        Christian EhrlicherC Offline
                        Christian EhrlicherC Offline
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote on last edited by
                        #10

                        If you want a ui file which works with uic from Qt4 you must use a designer from Qt4 and not one from Qt5 or Qt6 as they produce a xml file which can not be properly parsed with the ancient Qt4 uic. I already told you this in my first post here.

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

                        CP71C 1 Reply Last reply
                        2
                        • Christian EhrlicherC Christian Ehrlicher

                          If you want a ui file which works with uic from Qt4 you must use a designer from Qt4 and not one from Qt5 or Qt6 as they produce a xml file which can not be properly parsed with the ancient Qt4 uic. I already told you this in my first post here.

                          CP71C Offline
                          CP71C Offline
                          CP71
                          wrote on last edited by
                          #11

                          @Christian-Ehrlicher
                          I understand, but then I don't understand how I didn't notice UI issues until now.

                          If I understand correctly, I am using a Qt5 design (QtCreator) with incompatible UIC (Qt4) without ever encountering any issues, how is that possible?

                          "Anyway, thanks for the info, I'll proceed to downgrade QtCreator based on Qt4

                          Christian EhrlicherC 1 Reply Last reply
                          0
                          • CP71C CP71

                            @Christian-Ehrlicher
                            I understand, but then I don't understand how I didn't notice UI issues until now.

                            If I understand correctly, I am using a Qt5 design (QtCreator) with incompatible UIC (Qt4) without ever encountering any issues, how is that possible?

                            "Anyway, thanks for the info, I'll proceed to downgrade QtCreator based on Qt4

                            Christian EhrlicherC Offline
                            Christian EhrlicherC Offline
                            Christian Ehrlicher
                            Lifetime Qt Champion
                            wrote on last edited by
                            #12

                            There is no need to downgrade QtCreator. Just edit your ui files with the correct designer executable instead inside QtCreator.

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

                            CP71C 1 Reply Last reply
                            1
                            • Christian EhrlicherC Christian Ehrlicher

                              There is no need to downgrade QtCreator. Just edit your ui files with the correct designer executable instead inside QtCreator.

                              CP71C Offline
                              CP71C Offline
                              CP71
                              wrote on last edited by
                              #13

                              @Christian-Ehrlicher
                              Thank you, I like it better this way. ;)

                              Just out of curiosity, do you have any idea why I've never seen any UI issues in the VM?

                              1 Reply Last reply
                              0
                              • CP71C CP71 has marked this topic as solved on

                              • Login

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