Results 1 to 4 of 4

Thread: Ruler widget implementation

  1. #1
    Join Date
    Sep 2014
    Posts
    14
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default 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!

    icsrulerwidget.cpp
    icsrulerwidget.h
    Last edited by golubevsv; 16th October 2014 at 11:56.

  2. #2
    Join Date
    Oct 2015
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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)

  3. #3
    Join Date
    Feb 2006
    Location
    US
    Posts
    173
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Ruler widget implementation

    Can you provide a complete example?
    If not, I plan to build one ... hopefully using your Ruler implementation.

  4. #4
    Join Date
    Jul 2016
    Posts
    1

    Default Re: Ruler widget implementation

    Have you build it?
    I have the same problems which errors.

Similar Threads

  1. Looking for advices to do a ruler plus other questions
    By raphael.lencrerot in forum Qwt
    Replies: 7
    Last Post: 5th February 2015, 21:52
  2. Qt Multitouch implementation
    By sonulohani in forum Qt Programming
    Replies: 0
    Last Post: 7th June 2012, 06:51
  3. ruler in text area
    By santhosh in forum Newbie
    Replies: 1
    Last Post: 25th March 2011, 11:52
  4. tab order implementation
    By yazwas in forum Qt Programming
    Replies: 2
    Last Post: 2nd December 2009, 16:34
  5. Help,I want to make a ruler,all the code is here
    By duduqq in forum Qt Programming
    Replies: 4
    Last Post: 22nd April 2008, 07:08

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.