2 Attachment(s)
Ruler widget implementation
Hello all. I've found, that many people trying to implement on-screen "ruler" and smth like Office text editor with rulers in millimeters/centimeters. In my program i implement this functionality. Is has some builtins:
1. builtin resource paths for marker images. It can be found in CPP-file and modified to your paths.
2. Image sizes must be 16x16 pixels.
This ruler has rich functionality:
1. Possible to set ruler maximum value via setMaximum (in millimeters)
2. Possible to "scroll" ruler via setOrigin(in screen pixels starting from zero). This implemented as public slot and typically attached to scrollbar valueChanged signal.
3. Possible to define multiple markers, each has range, defining possible moving range (via setMarkerRange). Also, markers can be inverted(for example, right-margin marker will be inverted and its value calculated from right document edge).
4. Possible to catch all value changing stages via markerValueAboutToBeChanged, markerValueChanging, markerValueChanged. In my application i uses this signals to perform correct interaction with QRubberBand on parent widget.
5. Ruler can be vertical or horizontal. Orientation cannot be changed after marker creations ((
Rulers correctly reports its size hint and can be easily used in layouts.
NOTE: marker values/ranges in millimeters.
Example of usage in my app:
widget with QGridLayout on it, horizontal ruler at top side, vertical ruler at left side and QScrollArea at client. Rulers attaches to scroll area scrollbars accordingly orientation.
Enjoy!
Attachment 10669
Attachment 10670
Re: Ruler widget implementation
Would have been nice with a tiny example application for us newbies to get going and visualizing the capabilities of your work.
Sad to say, but I got overwhelmed by some 70 compiler errors trying to include your class in a simple Qt Widget Project () before abandoning it.
(Tried it on my QT4.8)
Re: Ruler widget implementation
Can you provide a complete example?
If not, I plan to build one ... hopefully using your Ruler implementation.
Re: Ruler widget implementation
Have you build it?
I have the same problems which errors.