Results 1 to 6 of 6

Thread: Use an image as QwtDialNeedle

  1. #1
    Join Date
    Oct 2017
    Posts
    25
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Use an image as QwtDialNeedle

    I see Qwt comes with examples on QwtDial and QwtDialNeedle.
    I wonder if it's possible to use a custom image as QwtDialNeedle.
    I think it should be necessary to re-implement the virtual functions of QwtDialNeedle (draw, setPalette, drawNeedle, ...) and then it should work.

    Can someone confirm this, please?
    Is there a working example somewhere?

    Thanks

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Use an image as QwtDialNeedle

    Overloading the QwtDialNeedle::setPalette doesn't make much sense - you can't do much with it.
    QwtDialNeedle::draw sets up a transformation matrix, according to the direction and then calls drawNeedle, what should be o.k for your situation.

    So you only need to overload drawNeedle and maybe drawKnob - if you have such a thing.

    Of course you only will have results without aliasing effects, when using a vector graphics format like SVG - in case your type of dial rotates the needle.

    Uwe

  3. #3
    Join Date
    Oct 2017
    Posts
    25
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Use an image as QwtDialNeedle

    Following your suggestion I've been able to get what I need (i.e. a dial with an image as a needle; the needle rotates; the image is a png).

    Everything works fine when I build my application for Windows 7 x86 (Qt 4.8.4).
    When I cross-compile to CE 6 (Qt 4.8.4) the needle is not drawn properly when the direction is 180° (i.e. 9 o'clock).
    Sometimes it's not drawn at all, sometimes is partially drawn, ...

    Could this be a matter of aliasing effect?

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Use an image as QwtDialNeedle

    Quote Originally Posted by vix View Post
    Could this be a matter of aliasing effect?
    Don't think so,
    Uwe

  5. #5
    Join Date
    Oct 2017
    Posts
    25
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Use an image as QwtDialNeedle

    I implemeted a dirty workaround: when the direction is between 179.9 and 180.1, set the direction itself to 180.1.
    The little displacement is not an issue for my application and so in this way everything is ok both on Win 7 and in CE 6.

    Do you have any idea on what could be the reason for this behavior?

  6. #6
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Use an image as QwtDialNeedle

    Maybe a division by zero - but without knowing your code this is pure speculation.

    Uwe

Similar Threads

  1. Replies: 0
    Last Post: 10th February 2018, 11:40
  2. Replies: 1
    Last Post: 18th October 2015, 13:06
  3. Replies: 15
    Last Post: 24th July 2015, 23:33
  4. Replies: 3
    Last Post: 3rd August 2012, 11:35

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.