Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Detect Rich Text in QML

Detect Rich Text in QML

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 3 Posters 3.7k 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.
  • T Offline
    T Offline
    talmage
    wrote on last edited by
    #1

    Is there an easy way for a Text element to know if its text is Rich Text? I need this for an application that will center unformatted text but display Rich Text as given.

    I'm hoping that "Qt::mightBeRichText()":http://developer.qt.nokia.com/doc/qt-4.8/qt.html#mightBeRichText has been secretly exposed to QML and that I've simply missed it in the Fine Manual. :-)

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mbrasser
      wrote on last edited by
      #2

      For QtQuick 1.x, the Text element internally uses Qt::mightBeRichText() when textFormat is set to Text.AutoText (which is the default). Does this work for your case, or do you need something more?

      1 Reply Last reply
      0
      • T Offline
        T Offline
        talmage
        wrote on last edited by
        #3

        I need something more. I am looking for a way to detect Rich Text myself so that I can apply additional formatting, such as setting horizontalAlignment, to plain text. It is not sufficient to use Text.AutoText.

        Can call Qt::mightBeRichText() from my QML application?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mbrasser
          wrote on last edited by
          #4

          Qt::mightBeRichText() isn't available from QML out-of-the-box -- you'd need to expose it from C++ yourself, or write similar functionality in JS.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            talmage
            wrote on last edited by
            #5

            That's what I feared. Thanks, mbrasser.

            1 Reply Last reply
            0
            • T Offline
              T Offline
              task_struct
              wrote on last edited by
              #6

              Hi,

              you can use onTextChanged signal in Text element to parse for HTML tags or something like this.

              "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

              • Linu...
              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