Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Unsolved QQuickImageProvider not recieving Unicode from Qml - cannot find image

    QML and Qt Quick
    2
    2
    379
    Loading More Posts
    • 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
      T_Eng last edited by

      Hi,
      I am building an application with a QML image source that is set from C++ backend. My problem being the QQuickImageProvider I have attached to my application engine as an image provider takes in the image source data as a QString in the requestPixmap function - using the example provided in QQuickImageProvider doc

      class ColorImageProvider : public QQuickImageProvider
      {
      public:
          ColorImageProvider()
              : QQuickImageProvider(QQuickImageProvider::Pixmap)
          {
          }
      
          QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
          {
              int width = 100;
              int height = 50;
      
              if (size)
                  *size = QSize(width, height);
              QPixmap pixmap(requestedSize.width() > 0 ? requestedSize.width() : width,
                             requestedSize.height() > 0 ? requestedSize.height() : height);
              pixmap.fill(QColor(id).rgba());
      
              return pixmap;
          }
      };
      

      How can I ensure the Unicode string properly propagates from C++ backend to QML back to QQuickImageProvider::requestPixmap()?

      Thanks!

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        Can you show how you are using your provider in your code ? As well as an example of string ?

        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 Reply Quote 0
        • First post
          Last post