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!
icsrulerwidget.cpp
icsrulerwidget.h
Bookmarks