Results 1 to 5 of 5

Thread: Timebar Widget - What is the best approach to implement this in Qt?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2012
    Posts
    22
    Thanks
    1

    Default Timebar Widget - What is the best approach to implement this in Qt?

    Hi everyone,

    I am in need of a Timebar widget and would like some advice on how to best implement this in Qt. To give you a better idea, I attached two rough drawings of the widget at two different zoom levels:
    drawing.jpg

    The widget should provide the following main features:
    - on top a basic timeline
    - timestamps shown at regular intervals
    - markers (and other things) that can be positioned and interacted with at various timepoints
    - scrolling horizontally
    - a zoom function (you can see in the picture that this should only increase the time-resolution and things like markers, timestamps etc are not changed in size)
    - timestamps (and other things) are shown/hidden dynamically based on the zoom level

    My first idea was to use a QGraphicsScene/-View for this, because those provide many of the elements I want.
    I wrote a quick prototype and ran into the problem that the large number of timestamps and vertical time-point bars quickly causes performance issues.
    Let's say I want to represent a timespan of only 1h up to miliseconds, that's already 3600000 timestamp objects that need to be shown/hidden based on the zoom level.
    How could this be implemented in a less performance hungry way?

    Thanks for any hints,
    xdn

  2. #2
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Timebar Widget - What is the best approach to implement this in Qt?

    I would start with a blank QWidget and manually implement all the custom drawing in the QPaintEvent and the handling in the QMouseEvents and QKeyboardEvents. It doesn't seem like an overly complex widget, so it wouldn't be so much work, but you do have specific requirements that are not delivered out of the box by existing components. Most of the drawing can be done by drawing lines here and there. You would get maximum performance by knowing exactly what and where to draw at a specific zoom level as opposed to the graphics view framework's generic methods of object selection. Drawing more than three million lines will take forever, no matter which method you use, but if you do it yourself, you can intelligently compute which lines you do need to draw and which ones you do not. For example, your screen can only show maybe 2000 pixels in the horizontal direction depending on your resolution. There is no point to ever draw more lines than that.

  3. #3
    Join Date
    Nov 2012
    Posts
    22
    Thanks
    1

    Default Re: Timebar Widget - What is the best approach to implement this in Qt?

    I see. Starting from scratch (as in QWidget) would certainly give me the greatest flexibility.
    I've never done much in the way of using paintEvents and I'm sure there are quite a few mistakes one can make to cripple drawing performance.
    Do you happen to know any good custom widget examples that I could look into to get me started?

Similar Threads

  1. QT implement for interacting Web Widget
    By ravikumar in forum Qt Programming
    Replies: 0
    Last Post: 22nd January 2012, 09:43
  2. Replies: 4
    Last Post: 11th April 2011, 09:56
  3. Reusing the same widget to implement "split-screen"
    By thomab in forum Qt Programming
    Replies: 3
    Last Post: 29th January 2011, 15:57
  4. Replies: 2
    Last Post: 19th February 2009, 19:37
  5. how to implement this widget
    By pencilren in forum Qt Programming
    Replies: 2
    Last Post: 15th June 2007, 11:10

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
  •  
Qt is a trademark of The Qt Company.