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 to get magnifier.exe effect in qt desktop application using cpp code.
QtWS25 Last Chance

How to get magnifier.exe effect in qt desktop application using cpp code.

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 945 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.
  • N Offline
    N Offline
    NageswaRao
    wrote on last edited by NageswaRao
    #1

    Hi everyone, I'm new very new to QT. Here, they are having one checkbox. so when we clicked on that checkbox, we are loading some 'third party service' called 'magnifier.exe', so some small window is opening on the application. So we are able to 'zoom In' and 'Zoom Out' in that small window. This same functionality I need to achieve using CPP. Is it possible? I searched on google most of the examples are using 'magnifier.exe' only. Any idea, thanks in advance.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      Yes its possible but drawing on the desktop to show where the "frame" is the most work and
      not that easy to do cross-platform.

      However, the zoom effect can be easy made like

          auto updateTimer = new QTimer(this);
          connect( updateTimer, &QTimer::timeout, this, [this]() {
      
              QPoint mp = QCursor::pos();
              auto scr = qApp->primaryScreen();
              QRect screenGeometry = scr->virtualGeometry();
              QPixmap  screenPixmap = scr->grabWindow(qApp->desktop()->winId(),
                                                      screenGeometry.x() + mp.x(), screenGeometry.y() + mp.y(), 100, 100);
      
              QPixmap scaled = screenPixmap.scaledToWidth(140, Qt::SmoothTransformation);
              ui->label->setPixmap(scaled);
          });
      
          updateTimer->start(10);
      

      This is just test code and should be optimized and the grab area centered around the cursor.

      alt text

      1 Reply Last reply
      4
      • N Offline
        N Offline
        NageswaRao
        wrote on last edited by NageswaRao
        #3

        @mrjj said in How to get magnifier.exe effect in qt desktop application using cpp code.:

        Yes its possible but drawing on the desktop to show where the "frame" is the most work and
        not that easy to do cross-platform.

        Thank you, MRJJ. My doubt is From the QT IDE, if I run a project, then it will open QMainWindow . So in that window, at the top, I'll keep one checkbox. So when we click that checkbox it should open a zoom in/Zoom out using mouse scroll related window. To achieve that, does the code that you provided previously is enough or I need to write more code to achieve that zoom in/out effect.

        OR from the following link(i.e https://sourceforge.net/projects/qt-magnification-glass-widget/), I downloaded one zip file. In that project, they are using Magnifier Galss for zoom in/out in the image only in that sample application. That downloaded sample application working when I run the application in my local system. I got an idea, why don't we use Magnifier Glass for my requirement. Will that work or I need to implement your idea.

        mrjjM 1 Reply Last reply
        0
        • N NageswaRao

          @mrjj said in How to get magnifier.exe effect in qt desktop application using cpp code.:

          Yes its possible but drawing on the desktop to show where the "frame" is the most work and
          not that easy to do cross-platform.

          Thank you, MRJJ. My doubt is From the QT IDE, if I run a project, then it will open QMainWindow . So in that window, at the top, I'll keep one checkbox. So when we click that checkbox it should open a zoom in/Zoom out using mouse scroll related window. To achieve that, does the code that you provided previously is enough or I need to write more code to achieve that zoom in/out effect.

          OR from the following link(i.e https://sourceforge.net/projects/qt-magnification-glass-widget/), I downloaded one zip file. In that project, they are using Magnifier Galss for zoom in/out in the image only in that sample application. That downloaded sample application working when I run the application in my local system. I got an idea, why don't we use Magnifier Glass for my requirement. Will that work or I need to implement your idea.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          @NageswaRao
          Hi
          qt-magnification-glass-widget is much better.
          Seems also have a widget etc.
          My code merely shows the zoom effect where mouse is.
          So good found! :)

          Update:
          Tested the qt-magnification-glass-widget
          Looks good but it seems to be only inside the app. I assume you need to allow this zoom
          outside of the app ? or is it fine its only inside your app ?

          N 1 Reply Last reply
          0
          • mrjjM mrjj

            @NageswaRao
            Hi
            qt-magnification-glass-widget is much better.
            Seems also have a widget etc.
            My code merely shows the zoom effect where mouse is.
            So good found! :)

            Update:
            Tested the qt-magnification-glass-widget
            Looks good but it seems to be only inside the app. I assume you need to allow this zoom
            outside of the app ? or is it fine its only inside your app ?

            N Offline
            N Offline
            NageswaRao
            wrote on last edited by
            #5

            @mrjj Thank you. I need to use Zoom in/out only the inside app only.

            1 Reply Last reply
            1

            • Login

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