PDA

View Full Version : Ruler widget implementation



golubevsv
16th October 2014, 11:51
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!

10669
10670

Manni
14th October 2015, 09:38
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)

brcain
19th November 2015, 20:01
Can you provide a complete example?
If not, I plan to build one ... hopefully using your Ruler implementation.

Max00
26th July 2016, 09:21
Have you build it?
I have the same problems which errors.