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. <font family> gets removed from .ui header files after upgrading Qt Creator from v5 to v6 ?
QtWS25 Last Chance

<font family> gets removed from .ui header files after upgrading Qt Creator from v5 to v6 ?

Scheduled Pinned Locked Moved Solved General and Desktop
qfontfontfont familyfonts
21 Posts 4 Posters 4.1k 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.
  • R Offline
    R Offline
    R-P-H
    wrote on 2 Feb 2022, 20:31 last edited by R-P-H 2 Apr 2022, 14:36
    #1

    Hi, I upgraded from Qt v5.14.0 to v5.15.2.

    When opening my v5.14.0 projects with the new version; I noticed that the font in all my ui files reset to default 'Segoe'. Comparing the ui header files from my v5.14.0 build and v5.15.2 builds I noticed that the lines font.setFamily(QString::fromUtf8("Arial")); had simply disappeared along with font.setWeight(75);.

    This has occured on multiple projects that I have built with the newer version where the font family gets reset. What is going on ?

    v5.14.0 sample ui.h:

    QFont font;
    font.setFamily(QString::fromUtf8("Arial"));
    font.setPointSize(36);
    font.setBold(true);
    font.setWeight(75);
    label_2->setFont(font);
    

    v5.15.2 of the same file:

    QFont font;
    font.setPointSize(36);
    font.setBold(true);
    label_2->setFont(font);
    
    1 Reply Last reply
    0
    • C Online
      C Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 4 Feb 2022, 15:57 last edited by
      #15

      Fixed In Qt6.2.3 and Qt6.3 so I would guess when a new QtCreator is build with Qt6.2.3 it's fixed there too. See https://bugreports.qt.io/browse/QTBUG-98916

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

      R 1 Reply Last reply 4 Feb 2022, 20:44
      2
      • C Online
        C Online
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 2 Feb 2022, 21:48 last edited by
        #2

        @R-P-H said in font.setfamily() gets removed from ui header files after upgrading Qt ?:

        Qt v14.0 to v15.2

        I know Qt2, 3, 4,5 and 6 but not Qt14 nor Qt15

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

        R 1 Reply Last reply 3 Feb 2022, 05:47
        1
        • C Christian Ehrlicher
          2 Feb 2022, 21:48

          @R-P-H said in font.setfamily() gets removed from ui header files after upgrading Qt ?:

          Qt v14.0 to v15.2

          I know Qt2, 3, 4,5 and 6 but not Qt14 nor Qt15

          R Offline
          R Offline
          R-P-H
          wrote on 3 Feb 2022, 05:47 last edited by
          #3

          @Christian-Ehrlicher Sorry I meant 5.14.0 and 5.15.2.

          1 Reply Last reply
          0
          • C Offline
            C Offline
            ChrisW67
            wrote on 3 Feb 2022, 05:56 last edited by
            #4

            Are these "ui.h" files are those generated by Designer from your UI design?

            R 1 Reply Last reply 3 Feb 2022, 06:32
            0
            • C ChrisW67
              3 Feb 2022, 05:56

              Are these "ui.h" files are those generated by Designer from your UI design?

              R Offline
              R Offline
              R-P-H
              wrote on 3 Feb 2022, 06:32 last edited by
              #5

              @ChrisW67 These are the files generated after building. The lines are missing since they've been removed from the .ui file as well:

                   <widget class="QLabel" name="label_2">
                    <property name="font">
                     <font>
                      <pointsize>36</pointsize>
                      <bold>true</bold>
                     </font>
                    </property>
                   </widget>
              
              C 1 Reply Last reply 3 Feb 2022, 07:49
              0
              • C Online
                C Online
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on 3 Feb 2022, 06:34 last edited by
                #6

                So this has nothing to do with Qt but with QtCreator because QtCreator creates/modifies the ui files - did you update QtCreator? What QtCreator version do you currently use?

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

                R 1 Reply Last reply 4 Feb 2022, 14:32
                1
                • R R-P-H
                  3 Feb 2022, 06:32

                  @ChrisW67 These are the files generated after building. The lines are missing since they've been removed from the .ui file as well:

                       <widget class="QLabel" name="label_2">
                        <property name="font">
                         <font>
                          <pointsize>36</pointsize>
                          <bold>true</bold>
                         </font>
                        </property>
                       </widget>
                  
                  C Offline
                  C Offline
                  ChrisW67
                  wrote on 3 Feb 2022, 07:49 last edited by ChrisW67 2 Mar 2022, 07:52
                  #7

                  @R-P-H Building the project will not modify the Designer blah.ui file: it is an input to uic, not an output (ui_blah.h). Only a human being opening and saving the *.ui file will modify the file: either with Designer directly or through Qt Creator. I guess you could directly edit blah.ui, or have some process that generates it; that would be entirely your own problem.

                  For example, this blah.ui:

                  <?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>640</width>
                      <height>100</height>
                     </rect>
                    </property>
                    <property name="windowTitle">
                     <string>Form</string>
                    </property>
                    <layout class="QVBoxLayout" name="verticalLayout">
                     <item>
                      <widget class="QLabel" name="label_2">
                       <property name="font">
                        <font>
                         <family>Arial</family>
                         <pointsize>36</pointsize>
                         <weight>75</weight>
                         <bold>true</bold>
                        </font>
                       </property>
                       <property name="text">
                        <string>TextLabel</string>
                       </property>
                      </widget>
                     </item>
                    </layout>
                   </widget>
                   <resources/>
                   <connections/>
                  </ui>
                  

                  Does this when built with a 5.12 and 5.15 version:

                  $ md5sum blah.ui
                  3f305f74aa3e61c8776bdcc205674c5f  blah.ui
                  
                  $ qmake -v
                  QMake version 3.1
                  Using Qt version 5.12.8 in /usr/lib/x86_64-linux-gnu
                  $ uic blah.ui > ui_blah_5_12_8.h  
                  
                  $ ~/Qt/5.15.0/gcc_64/bin/uic blah.ui > ui_blah_5_15_0.h
                  
                  $ ~/Qt/5.15.2/gcc_64/bin/uic blah.ui > ui_blah_5_15_2.h
                  
                  $ md5sum blah.ui   # UNCHANGED
                  3f305f74aa3e61c8776bdcc205674c5f  blah.ui
                  
                  $ diff ui_blah_5_12_8.h ui_blah_5_15_0.h  # No difference on font definition
                  4c4
                  < ** Created by: Qt User Interface Compiler version 5.12.8
                  ---
                  > ** Created by: Qt User Interface Compiler version 5.15.0
                  52,53c52,53
                  <         Form->setWindowTitle(QApplication::translate("Form", "Form", nullptr));
                  <         label_2->setText(QApplication::translate("Form", "TextLabel", nullptr));
                  ---
                  >         Form->setWindowTitle(QCoreApplication::translate("Form", "Form", nullptr));
                  >         label_2->setText(QCoreApplication::translate("Form", "TextLabel", nullptr));
                  
                  $ diff ui_blah_5_15_0.h  ui_blah_5_15_2.h 
                  4c4
                  < ** Created by: Qt User Interface Compiler version 5.15.0
                  ---
                  > ** Created by: Qt User Interface Compiler version 5.15.2
                  

                  The resulting code looks like this in all cases:

                          QFont font;
                          font.setFamily(QString::fromUtf8("Arial"));
                          font.setPointSize(36);
                          font.setBold(true);
                          font.setWeight(75);
                          label_2->setFont(font);
                  
                  R 1 Reply Last reply 4 Feb 2022, 14:31
                  0
                  • C ChrisW67
                    3 Feb 2022, 07:49

                    @R-P-H Building the project will not modify the Designer blah.ui file: it is an input to uic, not an output (ui_blah.h). Only a human being opening and saving the *.ui file will modify the file: either with Designer directly or through Qt Creator. I guess you could directly edit blah.ui, or have some process that generates it; that would be entirely your own problem.

                    For example, this blah.ui:

                    <?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>640</width>
                        <height>100</height>
                       </rect>
                      </property>
                      <property name="windowTitle">
                       <string>Form</string>
                      </property>
                      <layout class="QVBoxLayout" name="verticalLayout">
                       <item>
                        <widget class="QLabel" name="label_2">
                         <property name="font">
                          <font>
                           <family>Arial</family>
                           <pointsize>36</pointsize>
                           <weight>75</weight>
                           <bold>true</bold>
                          </font>
                         </property>
                         <property name="text">
                          <string>TextLabel</string>
                         </property>
                        </widget>
                       </item>
                      </layout>
                     </widget>
                     <resources/>
                     <connections/>
                    </ui>
                    

                    Does this when built with a 5.12 and 5.15 version:

                    $ md5sum blah.ui
                    3f305f74aa3e61c8776bdcc205674c5f  blah.ui
                    
                    $ qmake -v
                    QMake version 3.1
                    Using Qt version 5.12.8 in /usr/lib/x86_64-linux-gnu
                    $ uic blah.ui > ui_blah_5_12_8.h  
                    
                    $ ~/Qt/5.15.0/gcc_64/bin/uic blah.ui > ui_blah_5_15_0.h
                    
                    $ ~/Qt/5.15.2/gcc_64/bin/uic blah.ui > ui_blah_5_15_2.h
                    
                    $ md5sum blah.ui   # UNCHANGED
                    3f305f74aa3e61c8776bdcc205674c5f  blah.ui
                    
                    $ diff ui_blah_5_12_8.h ui_blah_5_15_0.h  # No difference on font definition
                    4c4
                    < ** Created by: Qt User Interface Compiler version 5.12.8
                    ---
                    > ** Created by: Qt User Interface Compiler version 5.15.0
                    52,53c52,53
                    <         Form->setWindowTitle(QApplication::translate("Form", "Form", nullptr));
                    <         label_2->setText(QApplication::translate("Form", "TextLabel", nullptr));
                    ---
                    >         Form->setWindowTitle(QCoreApplication::translate("Form", "Form", nullptr));
                    >         label_2->setText(QCoreApplication::translate("Form", "TextLabel", nullptr));
                    
                    $ diff ui_blah_5_15_0.h  ui_blah_5_15_2.h 
                    4c4
                    < ** Created by: Qt User Interface Compiler version 5.15.0
                    ---
                    > ** Created by: Qt User Interface Compiler version 5.15.2
                    

                    The resulting code looks like this in all cases:

                            QFont font;
                            font.setFamily(QString::fromUtf8("Arial"));
                            font.setPointSize(36);
                            font.setBold(true);
                            font.setWeight(75);
                            label_2->setFont(font);
                    
                    R Offline
                    R Offline
                    R-P-H
                    wrote on 4 Feb 2022, 14:31 last edited by
                    #8

                    @ChrisW67 Hi, I will demonstrate what it does below.

                    Here is a excerpt from a .ui file I have within a project before opening it with Qt Creator:

                    <widget class="QLabel" name="myLabel">
                        <property name="geometry">
                         <rect>
                          <x>20</x>
                          <y>130</y>
                          <width>2171</width>
                          <height>61</height>
                         </rect>
                        </property>
                        <property name="font">
                         <font>
                          <family>Arial</family>
                          <pointsize>30</pointsize>
                         </font>
                        </property>
                        <property name="styleSheet">
                         <string notr="true">color: rgb(255, 0, 0);</string>
                        </property>
                        <property name="text">
                         <string/>
                        </property>
                    </widget>
                    

                    I now go ahead and open the project using Qt Creator:
                    Capture.PNG

                    After the project opens, here is the exact same excerpt from the same .ui file:

                       <widget class="QLabel" name="myLabel">
                        <property name="geometry">
                         <rect>
                          <x>20</x>
                          <y>130</y>
                          <width>2171</width>
                          <height>61</height>
                         </rect>
                        </property>
                        <property name="font">
                         <font>
                          <pointsize>30</pointsize>
                         </font>
                        </property>
                        <property name="styleSheet">
                         <string notr="true">color: rgb(255, 0, 0);</string>
                        </property>
                        <property name="text">
                         <string/>
                        </property>
                       </widget>
                    

                    As you can see, somehow the <font family> property has been removed without me modifying anything. All I did was open the project using a newer version of Qt/Qt Creator.

                    1 Reply Last reply
                    0
                    • C Christian Ehrlicher
                      3 Feb 2022, 06:34

                      So this has nothing to do with Qt but with QtCreator because QtCreator creates/modifies the ui files - did you update QtCreator? What QtCreator version do you currently use?

                      R Offline
                      R Offline
                      R-P-H
                      wrote on 4 Feb 2022, 14:32 last edited by
                      #9

                      @Christian-Ehrlicher said in font.setfamily() gets removed from ui header files after upgrading Qt ?:

                      So this has nothing to do with Qt but with QtCreator because QtCreator creates/modifies the ui files - did you update QtCreator? What QtCreator version do you currently use?

                      Yes at the same time I upgraded Qt I also upgraded Qt Creator from major version 5 to major version 6. I am currently using Qt Creator v6.0.0.

                      1 Reply Last reply
                      0
                      • C Online
                        C Online
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote on 4 Feb 2022, 14:33 last edited by
                        #10

                        Again:

                        So this has nothing to do with Qt but with QtCreator because QtCreator creates/modifies the ui files - did you update QtCreator? What QtCreator version do you currently use?

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

                        R C 2 Replies Last reply 4 Feb 2022, 14:34
                        0
                        • C Christian Ehrlicher
                          4 Feb 2022, 14:33

                          Again:

                          So this has nothing to do with Qt but with QtCreator because QtCreator creates/modifies the ui files - did you update QtCreator? What QtCreator version do you currently use?

                          R Offline
                          R Offline
                          R-P-H
                          wrote on 4 Feb 2022, 14:34 last edited by
                          #11

                          @Christian-Ehrlicher said in font.setfamily() gets removed from ui header files after upgrading Qt ?:

                          Again:

                          So this has nothing to do with Qt but with QtCreator because QtCreator creates/modifies the ui files - did you update QtCreator? What QtCreator version do you currently use?

                          Yes, I see and agree. Still doesn't seem to explain why it would remove all my font family properties ?

                          1 Reply Last reply
                          0
                          • C Christian Ehrlicher
                            4 Feb 2022, 14:33

                            Again:

                            So this has nothing to do with Qt but with QtCreator because QtCreator creates/modifies the ui files - did you update QtCreator? What QtCreator version do you currently use?

                            C Online
                            C Online
                            Christian Ehrlicher
                            Lifetime Qt Champion
                            wrote on 4 Feb 2022, 14:37 last edited by Christian Ehrlicher 2 Apr 2022, 14:37
                            #12

                            @Christian-Ehrlicher said in <font family> gets removed from .ui header files after upgrading Qt Creator from v5 to v6 ?:

                            What QtCreator version do you currently use?

                            for the third time...

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

                            R 1 Reply Last reply 4 Feb 2022, 14:52
                            0
                            • C Christian Ehrlicher
                              4 Feb 2022, 14:37

                              @Christian-Ehrlicher said in <font family> gets removed from .ui header files after upgrading Qt Creator from v5 to v6 ?:

                              What QtCreator version do you currently use?

                              for the third time...

                              R Offline
                              R Offline
                              R-P-H
                              wrote on 4 Feb 2022, 14:52 last edited by
                              #13

                              @Christian-Ehrlicher said in <font family> gets removed from .ui header files after upgrading Qt Creator from v5 to v6 ?:

                              @Christian-Ehrlicher said in <font family> gets removed from .ui header files after upgrading Qt Creator from v5 to v6 ?:

                              What QtCreator version do you currently use?

                              for the third time...

                              @R-P-H said in <font family> gets removed from .ui header files after upgrading Qt Creator from v5 to v6 ?:

                              @Christian-Ehrlicher said in font.setfamily() gets removed from ui header files after upgrading Qt ?:

                              So this has nothing to do with Qt but with QtCreator because QtCreator creates/modifies the ui files - did you update QtCreator? What QtCreator version do you currently use?

                              Yes at the same time I upgraded Qt I also upgraded Qt Creator from major version 5 to major version 6. I am currently using Qt Creator v6.0.0.

                              Capture.PNG

                              1 Reply Last reply
                              0
                              • C Online
                                C Online
                                Christian Ehrlicher
                                Lifetime Qt Champion
                                wrote on 4 Feb 2022, 15:04 last edited by
                                #14

                                Ok, can reproduce it with QtCreator 6.0.3. Happens only when the select font is the default font (Arial on Windows, Noto Sans on Linux in my case). Does not happen with Qt-Designer 5.15.x and also not with other attributes.

                                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
                                0
                                • C Online
                                  C Online
                                  Christian Ehrlicher
                                  Lifetime Qt Champion
                                  wrote on 4 Feb 2022, 15:57 last edited by
                                  #15

                                  Fixed In Qt6.2.3 and Qt6.3 so I would guess when a new QtCreator is build with Qt6.2.3 it's fixed there too. See https://bugreports.qt.io/browse/QTBUG-98916

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

                                  R 1 Reply Last reply 4 Feb 2022, 20:44
                                  2
                                  • C Christian Ehrlicher
                                    4 Feb 2022, 15:57

                                    Fixed In Qt6.2.3 and Qt6.3 so I would guess when a new QtCreator is build with Qt6.2.3 it's fixed there too. See https://bugreports.qt.io/browse/QTBUG-98916

                                    R Offline
                                    R Offline
                                    R-P-H
                                    wrote on 4 Feb 2022, 20:44 last edited by
                                    #16

                                    @Christian-Ehrlicher said in <font family> gets removed from .ui header files after upgrading Qt Creator from v5 to v6 ?:

                                    Fixed In Qt6.2.3 and Qt6.3 so I would guess when a new QtCreator is build with Qt6.2.3 it's fixed there too. See https://bugreports.qt.io/browse/QTBUG-98916

                                    So just to wait ?

                                    C 1 Reply Last reply 4 Feb 2022, 20:48
                                    0
                                    • R R-P-H
                                      4 Feb 2022, 20:44

                                      @Christian-Ehrlicher said in <font family> gets removed from .ui header files after upgrading Qt Creator from v5 to v6 ?:

                                      Fixed In Qt6.2.3 and Qt6.3 so I would guess when a new QtCreator is build with Qt6.2.3 it's fixed there too. See https://bugreports.qt.io/browse/QTBUG-98916

                                      So just to wait ?

                                      C Online
                                      C Online
                                      Christian Ehrlicher
                                      Lifetime Qt Champion
                                      wrote on 4 Feb 2022, 20:48 last edited by
                                      #17

                                      @R-P-H said in <font family> gets removed from .ui header files after upgrading Qt Creator from v5 to v6 ?:

                                      So just to wait ?

                                      You can also build QtCreator by your own if you want... if it's worth the trouble.

                                      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
                                      0
                                      • mumanM Offline
                                        mumanM Offline
                                        muman
                                        wrote on 11 Feb 2022, 17:06 last edited by muman 2 Nov 2022, 17:11
                                        #18

                                        Hello,

                                        This bug is causing me a lot of grief. Just upgraded to QtCreator 6.0.2 and now I lose all my fonts whenever I use QtCreator to edit my .ui files.

                                        Is there a date when this bug is expected to be finished. I am trying to remain sane as I use QtCreator but in the end I use VSCode for code editing and until now I used QtCreator to edit .ui files (and now that is broken).

                                        Thank you,
                                        Michael Uman
                                        Sr Firmware Engineer
                                        Cana Technlogy

                                        1 Reply Last reply
                                        0
                                        • C Online
                                          C Online
                                          Christian Ehrlicher
                                          Lifetime Qt Champion
                                          wrote on 11 Feb 2022, 17:28 last edited by
                                          #19

                                          @muman said in <font family> gets removed from .ui header files after upgrading Qt Creator from v5 to v6 ?:

                                          Is there a date when this bug is expected to be finished

                                          As I already said - when a new QtCreator version is out, the bug will be fixed. You can also downgrade to an older version.

                                          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
                                          0
                                          • C Offline
                                            C Offline
                                            ChrisW67
                                            wrote on 11 Feb 2022, 23:15 last edited by
                                            #20

                                            Does the same problem exist if you use Qt 6.x Designer directly rather than as a component included in QtCreator?

                                            C 1 Reply Last reply 12 Feb 2022, 08:04
                                            0

                                            4/21

                                            3 Feb 2022, 05:56

                                            17 unread
                                            • Login

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