Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt Screenshot example not compiling With Qt5.x ?
Forum Updated to NodeBB v4.3 + New Features

Qt Screenshot example not compiling With Qt5.x ?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 2 Posters 292 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.
  • A Offline
    A Offline
    apclinux
    wrote on 8 Jul 2020, 14:50 last edited by
    #1

    Re: Qt Screenshot example not compiling With Qt5.x ?

    I'd just want to add that following code (very simple) which works perfectly
    to achieve full 1024 x 600 pixels screenshot of physical display on my target:

    QRect crop_rect(/*x*/0, /*y*/0, /*w*/1024, /*h*/600);
    QDesktopWidget *pDesk = QApplication::desktop();
    int id = pDesk->screenNumber();
    QImage desk = qApp->screens().at(0)->grabWindow(
        id,
        crop_rect.left(),
        crop_rect.top(),
        crop_rect.width(),
        crop_rect.height()).toImage();
    desk.save(QString("screen_%1x%2.png")
                .arg(crop_rect.width())
                .arg(crop_rect.height())
                /*,0,-1*/);
    

    --> this will save 1024 x 600 pixels screenshot as "screen_1024x600.png" image file that can be displayed by any image viewer application...

    ;^)

    Alain-Pierre (apclinux)

    J 1 Reply Last reply 9 Jul 2020, 05:30
    0
    • A apclinux
      8 Jul 2020, 14:50

      Re: Qt Screenshot example not compiling With Qt5.x ?

      I'd just want to add that following code (very simple) which works perfectly
      to achieve full 1024 x 600 pixels screenshot of physical display on my target:

      QRect crop_rect(/*x*/0, /*y*/0, /*w*/1024, /*h*/600);
      QDesktopWidget *pDesk = QApplication::desktop();
      int id = pDesk->screenNumber();
      QImage desk = qApp->screens().at(0)->grabWindow(
          id,
          crop_rect.left(),
          crop_rect.top(),
          crop_rect.width(),
          crop_rect.height()).toImage();
      desk.save(QString("screen_%1x%2.png")
                  .arg(crop_rect.width())
                  .arg(crop_rect.height())
                  /*,0,-1*/);
      

      --> this will save 1024 x 600 pixels screenshot as "screen_1024x600.png" image file that can be displayed by any image viewer application...

      ;^)

      Alain-Pierre (apclinux)

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 9 Jul 2020, 05:30 last edited by
      #2

      @apclinux And what is the problem?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply 9 Jul 2020, 17:42
      0
      • J jsulm
        9 Jul 2020, 05:30

        @apclinux And what is the problem?

        A Offline
        A Offline
        apclinux
        wrote on 9 Jul 2020, 17:42 last edited by
        #3

        @jsulm this was only a comment on initial request but link to initial request is not accessible (consider there is no problem for this example code) thx

        1 Reply Last reply
        0

        1/3

        8 Jul 2020, 14:50

        • Login

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