Results 1 to 4 of 4

Thread: Linear analog display

  1. #1
    Join Date
    Aug 2011
    Location
    Finland
    Posts
    18
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Question Linear analog display

    Yo!

    I'm trying to make a one-dimensional horizontal indicator that has a background color and on top of that a colored field whose width changes based on input: at 0% only background is seen, at 20% the leftmost fifth is colored with the foreground color and at 100% only foreground color is seen.

    I tried to go with two labels but I'm having trouble getting them to align right on top of each other in a layout. Any ideas?

    An additional difficulty: the width of this entire control is subject to change. How do I recompute the overlay size while avoiding infinite recursion in a resize event? I suspect layouts will not help here, since they will start shrinking the background label before starting to shrink the (smaller) overlay, distorting the displayed value.

    Thanks in advance, I really could use help on this one.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Linear analog display

    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Aug 2011
    Location
    Finland
    Posts
    18
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Linear analog display

    I did consider QProgressBar, but I was sceptical it could really be reliably styled to such a degree that it becomes as minimalistic as I described, on all/most platforms and themes. But apparently it can.

    I suspect I will need a way to synchronize the relative widths of two widgets regardless... although I suppose I could take a look at QProgressBar's source code.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Linear analog display

    You can always subclass it and provide your own painting by reimplementing paintEvent().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Curve brush with linear gradient?
    By liversedge in forum Qwt
    Replies: 2
    Last Post: 11th September 2011, 17:03
  2. Non-typical and Non-linear wizard
    By kornicameister in forum Qt Programming
    Replies: 4
    Last Post: 30th December 2010, 15:26
  3. Drawing a line with a linear gradient effect
    By toutarrive in forum Qt Programming
    Replies: 4
    Last Post: 15th February 2010, 07:42
  4. QprogressBar Style Sheets: double linear gradient
    By Beppe in forum Qt Programming
    Replies: 6
    Last Post: 8th May 2009, 14:41
  5. multiple page linear interface
    By ahkv9 in forum Qt Programming
    Replies: 3
    Last Post: 17th April 2007, 19:44

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.