Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How create dynamic arrays of QImage?

How create dynamic arrays of QImage?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 170 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.
  • L Offline
    L Offline
    loginmen
    wrote on 30 Jul 2021, 11:32 last edited by loginmen
    #1

    I want try something this

    void load(QImage *imgs) {
        //read number of images (int num)
        imgs = new QImage[num]{};
        for (uint i = 0; i < num; i++) {
            //read data (QByteArray data) from QFile
            QImage img{QImage::fromData(data, "PNG")};
            int w{img.width()};
            int h{img.height()};
            imgs[i] = img.scaled(w * scale, h *scale);
        }
    }
    

    But imgs outside has deleted QImage, operator= use & and not copy object(((
    Can use only dynamic arrays

    A 1 Reply Last reply 30 Jul 2021, 11:38
    0
    • L loginmen
      30 Jul 2021, 11:32

      I want try something this

      void load(QImage *imgs) {
          //read number of images (int num)
          imgs = new QImage[num]{};
          for (uint i = 0; i < num; i++) {
              //read data (QByteArray data) from QFile
              QImage img{QImage::fromData(data, "PNG")};
              int w{img.width()};
              int h{img.height()};
              imgs[i] = img.scaled(w * scale, h *scale);
          }
      }
      

      But imgs outside has deleted QImage, operator= use & and not copy object(((
      Can use only dynamic arrays

      A Offline
      A Offline
      artwaw
      wrote on 30 Jul 2021, 11:38 last edited by
      #2

      @loginmen why not QVector<QImage>?

      For more information please re-read.

      Kind Regards,
      Artur

      1 Reply Last reply
      4

      2/2

      30 Jul 2021, 11:38

      • Login

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