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. QTextEdit setting font often doesn't work
Forum Updated to NodeBB v4.3 + New Features

QTextEdit setting font often doesn't work

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 299 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.
  • C Offline
    C Offline
    clarify
    wrote on last edited by
    #1

    I'm trying to use QTextEdit and I want to be able to freely set the fonts of the text in the document.
    However I'm finding that often this operation doesn't work.
    Most common font names will not set i.e. the native equivalents of Courier, Arial and others are not automatically found and the set font operation fails.
    However sometimes it works.
    Does anyone know a reliable way to set the font such that the native equivalent font will be found and the operation will succeed every time?

    JoeCFDJ 1 Reply Last reply
    0
    • C clarify

      I'm trying to use QTextEdit and I want to be able to freely set the fonts of the text in the document.
      However I'm finding that often this operation doesn't work.
      Most common font names will not set i.e. the native equivalents of Courier, Arial and others are not automatically found and the set font operation fails.
      However sometimes it works.
      Does anyone know a reliable way to set the font such that the native equivalent font will be found and the operation will succeed every time?

      JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by
      #2

      @clarify if they can not be found automatically or not available on some machines, you can
      https://stackoverflow.com/questions/30973781/qt-add-custom-font-from-resource

      C 1 Reply Last reply
      0
      • JoeCFDJ JoeCFD

        @clarify if they can not be found automatically or not available on some machines, you can
        https://stackoverflow.com/questions/30973781/qt-add-custom-font-from-resource

        C Offline
        C Offline
        clarify
        wrote on last edited by clarify
        #3

        @JoeCFD
        I should clarify. What I'm doing is this:

        1. Load HTML file into QTextEdit which uses many fonts.
        2. Select-All (control-A)
        3. Set font.

        What I find is that the first paragraph is successfully changed, even to Courier. The rest of it cannot be changed.
        Sometimes I can set the entire document to the Gentium font, but not to any others.

        Second test:

        1. Load HTML file into QTextEdit which uses many fonts.
        2. Select any paragraph after the first.
        3. Set font.

        Observe that the font family will not change. Other characteristics can be changed e.g. bold, text color, text size.

        Third test:
        I just now added a little code to convert to native Linux font family names but that only helped a little. Some text still won't change. This is very discouraging. I assumed QTextEdit was better tested and less buggy than this. But I'm seeing bug after bug.

        Fourth test:
        Replace all SPAN tags in my HTML with FONT tags.
        That seems to work...

        JoeCFDJ 1 Reply Last reply
        0
        • C clarify

          @JoeCFD
          I should clarify. What I'm doing is this:

          1. Load HTML file into QTextEdit which uses many fonts.
          2. Select-All (control-A)
          3. Set font.

          What I find is that the first paragraph is successfully changed, even to Courier. The rest of it cannot be changed.
          Sometimes I can set the entire document to the Gentium font, but not to any others.

          Second test:

          1. Load HTML file into QTextEdit which uses many fonts.
          2. Select any paragraph after the first.
          3. Set font.

          Observe that the font family will not change. Other characteristics can be changed e.g. bold, text color, text size.

          Third test:
          I just now added a little code to convert to native Linux font family names but that only helped a little. Some text still won't change. This is very discouraging. I assumed QTextEdit was better tested and less buggy than this. But I'm seeing bug after bug.

          Fourth test:
          Replace all SPAN tags in my HTML with FONT tags.
          That seems to work...

          JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by JoeCFD
          #4

          @clarify Do not expect everything works smoothly. Try to fix bugs when they show up. That is a part of your job.

          C 1 Reply Last reply
          0
          • JoeCFDJ JoeCFD

            @clarify Do not expect everything works smoothly. Try to fix bugs when they show up. That is a part of your job.

            C Offline
            C Offline
            clarify
            wrote on last edited by clarify
            #5

            @JoeCFD I don't work for Qt, I'm just a user of their code.

            I'm working around their bugs, but it would be nicer if their bugs didn't exist in the first place. Or at least that they were documented somewhere. Their bugs are wasting my time.

            JoeCFDJ 1 Reply Last reply
            0
            • C clarify

              @JoeCFD I don't work for Qt, I'm just a user of their code.

              I'm working around their bugs, but it would be nicer if their bugs didn't exist in the first place. Or at least that they were documented somewhere. Their bugs are wasting my time.

              JoeCFDJ Offline
              JoeCFDJ Offline
              JoeCFD
              wrote on last edited by
              #6

              @clarify No, I did not mean you fix Qt bugs. You may try to work around the issues. Unluckily, bugs do exist in Qt or other software.

              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