How to Create an Interphase to load, edit and save image?
-
Hello Coders and developers
I want to make a graphical interface containing two windows two load and display images from desktop. In the first window the loaded image should be displayed and i want to perform some image operations like zoom in/out, use mouse to mark some points on image and draw lines on the image. The result of the image should be displayed in second window.
With help of QT widget application i can make windows to load images and display but i dont know how to use markings on the image and draw lines.
I am relly a beginner in C++ and QT is also new to me. Previously i worked on Matlab bt the coding is different in this.
Can anyone please say me how to do these steps. Any tutorial is all much helpful.
Thank you all -
Hi, and welcome to the Qt forum! The easiest way to draw lines etc on a widget is by using the QPainter API. Have a look at the Analog Clock Example.
-
@Wieland Thanks for your answer wieland, I have seen the analog clock example but it did not help me much. Scribbling example is a bit relevant for me as i want to paint on the image after execution and not during writing the code.
I do have one more question, how can we get the position of points on the image when we mark some points using pain?. To say it in simple, in the scribbling example if i mark two points using paint then the program should store the positions of that points. I could not find any functions like getPositions in QT or i hope i am not using relevant libraries.
-
I'm not completely sure what you mean. If you want to get the current position of the mouse cursor in coordinates relative the widget that displays your image then you can do this:
QPoint currentPosition = widget->mapFromGlobal( QCursor::pos() );