Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for WebAssembly
  4. QPlainTextEdit font
Servers for Qt installer are currently down

QPlainTextEdit font

Scheduled Pinned Locked Moved Solved Qt for WebAssembly
4 Posts 2 Posters 332 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.
  • D Offline
    D Offline
    driesz
    wrote on last edited by
    #1

    What is the correct way to specify the font of a widget in WebAssembly?

    I'm using QtCreator to build an application that includes the QPlainTextEdit widget. I'd like it to use a monospace font and I've tried specifying it in the Property Editor of the GUI builder. The font appears as expected when built as a desktop application, but not as a WebAssembly application (running in Firefox, FWIW).

    I've tried different text edit widgets, setDefaultFont(), setDefaultStyleSheet(), QTextDocument settings, setThis(), setThat() and have burned HOURS trying to get this to look right.

    In summary: Setting text edit widget font works in a desktop app, but not in a WASM app. What's the deal?

    Thanks in advance.

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

      Hi,

      As an educated guess: embed the font using Qt's resource system and use QFontDatabase to load it in your application before using it.

      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
      1
      • D Offline
        D Offline
        driesz
        wrote on last edited by
        #3

        Shouldn't I be able to somehow specify a generic "monospace" parameter that the browser can figure out on its own?

        I'll try your suggestion, but I'm not convinced there isn't an easier way to do it.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          driesz
          wrote on last edited by
          #4

          Well, you can't argue with results. Embedding the font as you suggested worked perfectly. Thank you for the suggestion!

          1 Reply Last reply
          1
          • D driesz 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