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. Show QImage in the QML Image
QtWS25 Last Chance

Show QImage in the QML Image

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 3 Posters 1.6k 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.
  • M Offline
    M Offline
    Milosz
    wrote on last edited by
    #1

    In C++ code I generate some picture and store it in QImage then I would like to show it in QML.

    C++:

    class InfoViewContent : public QQuickItem
    {
    ..............
    Q_INVOCABLE QImage getPage() 
    { 
          return m_image
    }
    .......................................................
    QImage m_image;
    }
    

    QML:

    Image {
        ...........
        InfoViewContent
        {
          ???
        }
        source: ???
    

    Is the way is proper?
    how can I manege it?

    Thanks in advance

    raven-worxR J.HilkJ 2 Replies Last reply
    0
    • M Milosz

      In C++ code I generate some picture and store it in QImage then I would like to show it in QML.

      C++:

      class InfoViewContent : public QQuickItem
      {
      ..............
      Q_INVOCABLE QImage getPage() 
      { 
            return m_image
      }
      .......................................................
      QImage m_image;
      }
      

      QML:

      Image {
          ...........
          InfoViewContent
          {
            ???
          }
          source: ???
      

      Is the way is proper?
      how can I manege it?

      Thanks in advance

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @Milosz
      When you depend on a Image element, the only way is via QQuickImageProvider approach
      Alternatively you can implement a custom painting QML item - e.g. derive QQuickPaintedItem for simple QPainter API usage

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • M Milosz

        In C++ code I generate some picture and store it in QImage then I would like to show it in QML.

        C++:

        class InfoViewContent : public QQuickItem
        {
        ..............
        Q_INVOCABLE QImage getPage() 
        { 
              return m_image
        }
        .......................................................
        QImage m_image;
        }
        

        QML:

        Image {
            ...........
            InfoViewContent
            {
              ???
            }
            source: ???
        

        Is the way is proper?
        how can I manege it?

        Thanks in advance

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        hi @Milosz

        usually, one uses a QQuickImageProvider to provide QML with a cpp QImage

        here a small example app I created to learn how to use the ImageProvider Class
        githublink


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        M 1 Reply Last reply
        1
        • J.HilkJ J.Hilk

          hi @Milosz

          usually, one uses a QQuickImageProvider to provide QML with a cpp QImage

          here a small example app I created to learn how to use the ImageProvider Class
          githublink

          M Offline
          M Offline
          Milosz
          wrote on last edited by
          #4

          @J.Hilk Thanks a lot - it is not simple but operates

          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