How to get magnifier.exe effect in qt desktop application using cpp code.
-
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.
-
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.
-
@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.
-
@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.
@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 ? -
@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 ?@mrjj Thank you. I need to use Zoom in/out only the inside app only.