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. Text.RichText <img> error
Forum Updated to NodeBB v4.3 + New Features

Text.RichText <img> error

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 181 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.
  • N Offline
    N Offline
    ndbrownlow
    wrote on last edited by ndbrownlow
    #1

    Using Qt 5.12.4. The following code:

    import QtQuick 2.13
    Text {
        id: text
        anchors.fill: parent
        text: '<img src="myimage.jpg" height="10" width="10">'
        baseUrl: "https://myserver.com/"
        textFormat: Text.RichText
    }
    

    generates the following error:

    QObject: Cannot create children for a parent that is in a different thread.(Parent is QQmlEngine(0x1f1087bc970), parent's thread is QThread(0x1f17e4c1450), current thread is QSGRenderThread(0x1f109cdb4f0)

    When the height and width are removed from the <img>, it's fine.

    Does anyone know why this error is occurring?

    1 Reply Last reply
    0
    • MarkkyboyM Offline
      MarkkyboyM Offline
      Markkyboy
      wrote on last edited by Markkyboy
      #2

      I'll go out on a limb here and say your syntax is wrong. I tackled this sometime ago for a client. I got there eventually.

      Your line for 'text';

      text: '<img src="myimage.jpg" height="10" width="10">'
      

      Should look like;

      text:  `<img src='myimage.jpg' height='10' width='10'>`
      

      The difference is not noticeable immediately, but looking closer, you'll notice that we have to use a backwards tick ( ` ) top open and close our line of text.

      Hope this helps. . .

      Here's how it looks from my project using a wifi logo image in a line of text;

      wifi-logo-in-text.JPG

      Don't just sit there standing around, pick up a shovel and sweep up!

      I live by the sea, not in it.

      1 Reply Last reply
      2

      • Login

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