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. Writing QGraphicsItemGroup to a .png file?

Writing QGraphicsItemGroup to a .png file?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.2k 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.
  • J Offline
    J Offline
    jesbb
    wrote on last edited by
    #1

    Is it possible to write a QGraphicsItemGroup (or the contents of a QGraphicsItemGroup) to an image file, specifically a .png? If it is, I'm not sure how to go about doing it.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kibsoft
      wrote on last edited by
      #2

      Maybe something like that :)

      @
      QImage img(item->boundingRect().size().toSize(), QImage::Format_RGB32);
      img.fill(QColor(255, 255, 255).rgb());
      QPainter painter(&img;);
      QStyleOptionGraphicsItem styleOption;
      item->paint(&painter;, &styleOption;);
      img.save(path);
      @

      where "item" is your QGraphicsItemGroup.

      P.S. I'm not sure, but you can try..

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jesbb
        wrote on last edited by
        #3

        [quote author="kibsoft" date="1311145041"]Maybe something like that :)

        @
        QImage img(item->boundingRect().size().toSize(), QImage::Format_RGB32);
        img.fill(QColor(255, 255, 255).rgb());
        QPainter painter(&img;);
        QStyleOptionGraphicsItem styleOption;
        item->paint(&painter;, &styleOption;);
        img.save(path);
        @

        where "item" is your QGraphicsItemGroup.

        P.S. I'm not sure, but you can try..[/quote]

        I tried doing that, but it doesn't work; it only returns a blank image that's the same dimension of the QGraphicsItemGroup.

        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