- Qt 5 and OpenCV 4 Computer Vision Projects
- Zhuo Qingliang
- 215字
- 2021-06-24 13:59:17
Zooming in and out
OK. We have successfully displayed the image. Now, let's scale it. Here, we take zooming in as an example. With the experience from the preceding actions, we should have a clear idea as to how to do that. First, we declare a private slot, which is named zoomIn, and give its implementation as shown in the following code:
void MainWindow::zoomIn()
{
imageView->scale(1.2, 1.2);
}
Easy, right? Just call the scale method of imageView with a scale rate for the width and a scale rate for the height. Then, we connect the triggered signal of zoomInAction to this slot in the createActions method of the MainWindow class:
connect(zoomInAction, SIGNAL(triggered(bool)), this, SLOT(zoomIn()));
Compile and run the application, open an image with it, and click on the Zoom in button on the toolbar. You will find that the image enlarges to 120% of its current size on each click.
Zooming out just entails scaling the imageView with a rate of less than 1.0. Please try to implement it by yourself. If you find it difficult, you can refer to our code repository on GitHub (https://github.com/PacktPublishing/Qt-5-and-OpenCV-4-Computer-Vision-Projects/tree/master/Chapter-01).
With our application, we can now open an image and scale it for viewing. Next, we will implement the function of the saveAsAction action.
- Unreal Engine Physics Essentials
- OpenDaylight Cookbook
- Android應用程序開發與典型案例
- Ext JS Data-driven Application Design
- PyQt從入門到精通
- Practical Data Science Cookbook(Second Edition)
- 軟件測試工程師面試秘籍
- Node.js:來一打 C++ 擴展
- Node Cookbook(Second Edition)
- Access 2010數據庫應用技術實驗指導與習題選解(第2版)
- 物聯網系統架構設計與邊緣計算(原書第2版)
- Python大規模機器學習
- 超好玩的Scratch 3.5少兒編程
- SEO教程:搜索引擎優化入門與進階(第3版)
- Java從入門到精通(視頻實戰版)