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. Invisible text in QTextEdit
Forum Update on Monday, May 27th 2025

Invisible text in QTextEdit

Scheduled Pinned Locked Moved Solved General and Desktop
ubuntu 16.04fontsqt 5.9c++
26 Posts 3 Posters 13.2k 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.
  • A Offline
    A Offline
    Alp Hancioglu
    wrote on 29 Aug 2017, 06:48 last edited by
    #1

    I am learning Qt and running examples from Qt SDK 5.9.1. I run the code below and write inside QTextEdit but no text appears. Cursor moves as I write but no text is shown. Window title text is shown.

     int main(int argc, char *argv[])
     {
       QApplication app(argc, argv);
    
       QFont font = QFontDatabase::systemFont(QFontDatabase::GeneralFont);
       std::cout << font.toString().toUtf8().constData();
       QFontDatabase database;
       QStringList fam = database.families();
       app.setFont(QFont("Ubuntu", 11, QFont::Normal, false));
    
       QTextEdit textEdit; 
       textEdit.show();
    
       return app.exec();
     }
    

    I tried to get system font using QFontDatabase but it didn't work:

    app.setFont(QFontDatabase::systemFont(QFontDatabase::GeneralFont));
    

    This doesn't do anything with any of enum values including QFontDatabase::GeneralFont

    QFont font = QFontDatabase::systemFont(QFontDatabase::GeneralFont);
    

    font prints Sans Serif,9,-1,5,50,0,0,0,0,00.

    QFontDatabase database;
    QStringList fam = database.families();
    

    fam size is zero.

    I built qt from source using the instructions here. How can I fix this and set the app font to default ubuntu font?

    My specs:
    Ubuntu 16.04
    Qt 5.9.1

    J 1 Reply Last reply 29 Aug 2017, 06:55
    0
    • A Alp Hancioglu
      29 Aug 2017, 06:48

      I am learning Qt and running examples from Qt SDK 5.9.1. I run the code below and write inside QTextEdit but no text appears. Cursor moves as I write but no text is shown. Window title text is shown.

       int main(int argc, char *argv[])
       {
         QApplication app(argc, argv);
      
         QFont font = QFontDatabase::systemFont(QFontDatabase::GeneralFont);
         std::cout << font.toString().toUtf8().constData();
         QFontDatabase database;
         QStringList fam = database.families();
         app.setFont(QFont("Ubuntu", 11, QFont::Normal, false));
      
         QTextEdit textEdit; 
         textEdit.show();
      
         return app.exec();
       }
      

      I tried to get system font using QFontDatabase but it didn't work:

      app.setFont(QFontDatabase::systemFont(QFontDatabase::GeneralFont));
      

      This doesn't do anything with any of enum values including QFontDatabase::GeneralFont

      QFont font = QFontDatabase::systemFont(QFontDatabase::GeneralFont);
      

      font prints Sans Serif,9,-1,5,50,0,0,0,0,00.

      QFontDatabase database;
      QStringList fam = database.families();
      

      fam size is zero.

      I built qt from source using the instructions here. How can I fix this and set the app font to default ubuntu font?

      My specs:
      Ubuntu 16.04
      Qt 5.9.1

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 29 Aug 2017, 06:55 last edited by jsulm
      #2

      @Alp-Hancioglu Does it work if you don't set any font? Do other Qt apps work (like VCL)?
      Also: how did you install Qt?

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

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Alp Hancioglu
        wrote on 29 Aug 2017, 07:04 last edited by Alp Hancioglu
        #3

        It doesn't work if I don't set any font.
        Do you mean VLC media player? I just installed VLC and it also doesn't display any text. It only displays window headers and menu items.
        I built qt from source as I said in my post.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          karlheinzreichel
          wrote on 29 Aug 2017, 07:46 last edited by
          #4

          Hmm.. according to your code:
          When you do not set a text in the QTextEdit-Control (textEdit.setPlainText)
          there will be no visible text in the control!

          A 1 Reply Last reply 29 Aug 2017, 07:55
          0
          • K karlheinzreichel
            29 Aug 2017, 07:46

            Hmm.. according to your code:
            When you do not set a text in the QTextEdit-Control (textEdit.setPlainText)
            there will be no visible text in the control!

            A Offline
            A Offline
            Alp Hancioglu
            wrote on 29 Aug 2017, 07:55 last edited by
            #5

            @karlheinzreichel I don't understand what you mean exactly but textEdit.append("some"); call doesn't display any text either. It moves the cursor but no text is shown.

            K 1 Reply Last reply 29 Aug 2017, 07:58
            0
            • A Alp Hancioglu
              29 Aug 2017, 07:55

              @karlheinzreichel I don't understand what you mean exactly but textEdit.append("some"); call doesn't display any text either. It moves the cursor but no text is shown.

              K Offline
              K Offline
              karlheinzreichel
              wrote on 29 Aug 2017, 07:58 last edited by
              #6

              @Alp-Hancioglu
              in your code above there is no append (or did I miss something ?)

              A 1 Reply Last reply 29 Aug 2017, 08:01
              0
              • K karlheinzreichel
                29 Aug 2017, 07:58

                @Alp-Hancioglu
                in your code above there is no append (or did I miss something ?)

                A Offline
                A Offline
                Alp Hancioglu
                wrote on 29 Aug 2017, 08:01 last edited by
                #7

                @karlheinzreichel I tried the append call at some point but forgot to add it to the post. The issue seems much more bigger than QTextEdit though as there is also no text shown in VLC media player.

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  karlheinzreichel
                  wrote on 29 Aug 2017, 08:08 last edited by
                  #8

                  As you build qt from scratch, the question :
                  Have you installed the libconfig libraries before ... ?

                  (probably not)

                  regards
                  karl-heinz

                  A 1 Reply Last reply 29 Aug 2017, 08:13
                  0
                  • K karlheinzreichel
                    29 Aug 2017, 08:08

                    As you build qt from scratch, the question :
                    Have you installed the libconfig libraries before ... ?

                    (probably not)

                    regards
                    karl-heinz

                    A Offline
                    A Offline
                    Alp Hancioglu
                    wrote on 29 Aug 2017, 08:13 last edited by
                    #9

                    @karlheinzreichel I didn't explicitly install libconfig library myself. I don't know if other program installed it as prerequisite.
                    In order to build, I downloaded qt-everywhere-opensource-src-5.9.1.tar.xz file and extracted it.
                    Then called ./configure and make on bash.

                    J 1 Reply Last reply 29 Aug 2017, 08:36
                    0
                    • K Offline
                      K Offline
                      karlheinzreichel
                      wrote on 29 Aug 2017, 08:16 last edited by
                      #10

                      So I would reccomend to check the build requierments for QT
                      (see http://doc.qt.io/qt-5/linux-requirements.html)
                      before building the qt libs

                      regards
                      Karl-Heinz

                      A 1 Reply Last reply 29 Aug 2017, 13:11
                      1
                      • A Alp Hancioglu
                        29 Aug 2017, 08:13

                        @karlheinzreichel I didn't explicitly install libconfig library myself. I don't know if other program installed it as prerequisite.
                        In order to build, I downloaded qt-everywhere-opensource-src-5.9.1.tar.xz file and extracted it.
                        Then called ./configure and make on bash.

                        J Offline
                        J Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on 29 Aug 2017, 08:36 last edited by
                        #11

                        @Alp-Hancioglu Try to start your app with QT_DEBUG_PLUGINS environment variable set and check the output in the console. Looks like something is wrong with your system.

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

                        A 1 Reply Last reply 29 Aug 2017, 09:24
                        0
                        • J jsulm
                          29 Aug 2017, 08:36

                          @Alp-Hancioglu Try to start your app with QT_DEBUG_PLUGINS environment variable set and check the output in the console. Looks like something is wrong with your system.

                          A Offline
                          A Offline
                          Alp Hancioglu
                          wrote on 29 Aug 2017, 09:24 last edited by
                          #12

                          @jsulm I set the env variable and there are no errors listed. Just a bunch of plugin metadata loads. Should I look for something?

                          J 1 Reply Last reply 29 Aug 2017, 10:35
                          0
                          • A Alp Hancioglu
                            29 Aug 2017, 09:24

                            @jsulm I set the env variable and there are no errors listed. Just a bunch of plugin metadata loads. Should I look for something?

                            J Offline
                            J Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on 29 Aug 2017, 10:35 last edited by
                            #13

                            @Alp-Hancioglu Are there any errors/warnings?

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

                            A 1 Reply Last reply 29 Aug 2017, 12:58
                            0
                            • J jsulm
                              29 Aug 2017, 10:35

                              @Alp-Hancioglu Are there any errors/warnings?

                              A Offline
                              A Offline
                              Alp Hancioglu
                              wrote on 29 Aug 2017, 12:58 last edited by
                              #14

                              @jsulm There are no errors or warnings.

                              1 Reply Last reply
                              0
                              • K karlheinzreichel
                                29 Aug 2017, 08:16

                                So I would reccomend to check the build requierments for QT
                                (see http://doc.qt.io/qt-5/linux-requirements.html)
                                before building the qt libs

                                regards
                                Karl-Heinz

                                A Offline
                                A Offline
                                Alp Hancioglu
                                wrote on 29 Aug 2017, 13:11 last edited by
                                #15

                                @karlheinzreichel I checked every package and its dev version listed in requirements list and they are all installed and at newest version so there is no need to install or upgrade any of them. Some packages don't have the exact same name on my machine: libfontconfig is listed as libfontconfig1 on mine, libfreetype is listed as libfreetype6 on mine but the descriptions match.
                                I built Qt a week ago so they were most probably at newest version at time of compilation so I don't think they are related to the issue I have.

                                J 1 Reply Last reply 30 Aug 2017, 04:10
                                0
                                • A Alp Hancioglu
                                  29 Aug 2017, 13:11

                                  @karlheinzreichel I checked every package and its dev version listed in requirements list and they are all installed and at newest version so there is no need to install or upgrade any of them. Some packages don't have the exact same name on my machine: libfontconfig is listed as libfontconfig1 on mine, libfreetype is listed as libfreetype6 on mine but the descriptions match.
                                  I built Qt a week ago so they were most probably at newest version at time of compilation so I don't think they are related to the issue I have.

                                  J Offline
                                  J Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on 30 Aug 2017, 04:10 last edited by
                                  #16

                                  @Alp-Hancioglu If you execute configure script before building Qt you will get a summary what was found and enabled. You can execute configure again with -v parameter and see whether fontconfig was really enabled.

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

                                  A 1 Reply Last reply 30 Aug 2017, 07:40
                                  0
                                  • J jsulm
                                    30 Aug 2017, 04:10

                                    @Alp-Hancioglu If you execute configure script before building Qt you will get a summary what was found and enabled. You can execute configure again with -v parameter and see whether fontconfig was really enabled.

                                    A Offline
                                    A Offline
                                    Alp Hancioglu
                                    wrote on 30 Aug 2017, 07:40 last edited by
                                    #17

                                    @jsulm Thanks for the continued support jsulm.

                                    I used ./configure -v and saw that fontconfig is disabled in build options:

                                    Qt Gui:
                                      Accessibility .......................... yes
                                      FreeType ............................... yes
                                        Using system FreeType ................ no
                                      HarfBuzz ............................... yes
                                        Using system HarfBuzz ................ no
                                      Fontconfig ............................. no
                                    

                                    Then I used ./configure -v -fontconfig to enable it but it didn't work with error:

                                    ERROR: Feature 'fontconfig' was enabled, but the pre-condition '!config.win32 && !config.darwin && features.system-freetype && libs.fontconfig' failed.
                                    

                                    Then I run following to make sure libfontconfig is installed:

                                    sudo apt install libfontconfig1
                                    [sudo] password for alp: 
                                    Reading package lists... Done
                                    Building dependency tree       
                                    Reading state information... Done
                                    libfontconfig1 is already the newest version (2.11.94-0ubuntu1.1).
                                    0 upgraded, 0 newly installed, 0 to remove and 39 not upgraded.
                                    

                                    I also run ./configure -system-freetype -fontconfig but it doesn't make a difference with resulting errors:

                                    ERROR: Feature 'system-freetype' was enabled, but the pre-condition 'features.freetype && libs.freetype' failed.
                                    
                                    ERROR: Feature 'fontconfig' was enabled, but the pre-condition '!config.win32 && !config.darwin && features.system-freetype && libs.fontconfig' failed.
                                    

                                    Make sure freetype is installed:

                                    sudo apt install libfreetype6
                                    Reading package lists... Done
                                    Building dependency tree       
                                    Reading state information... Done
                                    libfreetype6 is already the newest version (2.6.1-0.1ubuntu2.3).
                                    0 upgraded, 0 newly installed, 0 to remove and 39 not upgraded.
                                    
                                    J 1 Reply Last reply 30 Aug 2017, 08:01
                                    0
                                    • A Alp Hancioglu
                                      30 Aug 2017, 07:40

                                      @jsulm Thanks for the continued support jsulm.

                                      I used ./configure -v and saw that fontconfig is disabled in build options:

                                      Qt Gui:
                                        Accessibility .......................... yes
                                        FreeType ............................... yes
                                          Using system FreeType ................ no
                                        HarfBuzz ............................... yes
                                          Using system HarfBuzz ................ no
                                        Fontconfig ............................. no
                                      

                                      Then I used ./configure -v -fontconfig to enable it but it didn't work with error:

                                      ERROR: Feature 'fontconfig' was enabled, but the pre-condition '!config.win32 && !config.darwin && features.system-freetype && libs.fontconfig' failed.
                                      

                                      Then I run following to make sure libfontconfig is installed:

                                      sudo apt install libfontconfig1
                                      [sudo] password for alp: 
                                      Reading package lists... Done
                                      Building dependency tree       
                                      Reading state information... Done
                                      libfontconfig1 is already the newest version (2.11.94-0ubuntu1.1).
                                      0 upgraded, 0 newly installed, 0 to remove and 39 not upgraded.
                                      

                                      I also run ./configure -system-freetype -fontconfig but it doesn't make a difference with resulting errors:

                                      ERROR: Feature 'system-freetype' was enabled, but the pre-condition 'features.freetype && libs.freetype' failed.
                                      
                                      ERROR: Feature 'fontconfig' was enabled, but the pre-condition '!config.win32 && !config.darwin && features.system-freetype && libs.fontconfig' failed.
                                      

                                      Make sure freetype is installed:

                                      sudo apt install libfreetype6
                                      Reading package lists... Done
                                      Building dependency tree       
                                      Reading state information... Done
                                      libfreetype6 is already the newest version (2.6.1-0.1ubuntu2.3).
                                      0 upgraded, 0 newly installed, 0 to remove and 39 not upgraded.
                                      
                                      J Offline
                                      J Offline
                                      jsulm
                                      Lifetime Qt Champion
                                      wrote on 30 Aug 2017, 08:01 last edited by
                                      #18

                                      @Alp-Hancioglu You need to install the dev package for fontconfig. Something like libfontconfig1-dev.

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

                                      A 1 Reply Last reply 30 Aug 2017, 08:40
                                      0
                                      • J jsulm
                                        30 Aug 2017, 08:01

                                        @Alp-Hancioglu You need to install the dev package for fontconfig. Something like libfontconfig1-dev.

                                        A Offline
                                        A Offline
                                        Alp Hancioglu
                                        wrote on 30 Aug 2017, 08:40 last edited by
                                        #19

                                        @jsulm It is already installed:

                                        sudo apt install libfontconfig1-dev
                                        [sudo] password for alp: 
                                        Reading package lists... Done
                                        Building dependency tree       
                                        Reading state information... Done
                                        libfontconfig1-dev is already the newest version (2.11.94-0ubuntu1.1).
                                        0 upgraded, 0 newly installed, 0 to remove and 39 not upgraded.
                                        

                                        I checked every dev package in the requirements list and they are all installed with newest versions

                                        J 1 Reply Last reply 30 Aug 2017, 08:52
                                        0
                                        • A Alp Hancioglu
                                          30 Aug 2017, 08:40

                                          @jsulm It is already installed:

                                          sudo apt install libfontconfig1-dev
                                          [sudo] password for alp: 
                                          Reading package lists... Done
                                          Building dependency tree       
                                          Reading state information... Done
                                          libfontconfig1-dev is already the newest version (2.11.94-0ubuntu1.1).
                                          0 upgraded, 0 newly installed, 0 to remove and 39 not upgraded.
                                          

                                          I checked every dev package in the requirements list and they are all installed with newest versions

                                          J Offline
                                          J Offline
                                          jsulm
                                          Lifetime Qt Champion
                                          wrote on 30 Aug 2017, 08:52 last edited by
                                          #20

                                          @Alp-Hancioglu If you execute configure with -v you should get more output. Can you post it here?

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

                                          A 1 Reply Last reply 30 Aug 2017, 09:09
                                          1

                                          1/26

                                          29 Aug 2017, 06:48

                                          • Login

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