Results 1 to 10 of 10

Thread: setting an image backround(using qwt multi-axis)

  1. #1
    Join Date
    Dec 2016
    Posts
    26
    Thanks
    14
    Qt products
    Qt5
    Platforms
    Windows Android

    Default setting an image backround(using qwt multi-axis)

    I want to set the real city's map image to the background of the plot.
    What class of qwt I should use for this?
    I am using qwt multi-axis

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

    Default Re: setting an image backround(using qwt multi-axis)

    What type of format does your image have - some vector or raster graphic ?
    How is your image related to the plot axes - probably by knowing he bounding rectangle ?

    Uwe

  3. The following user says thank you to Uwe for this useful post:

    QJak (7th February 2019)

  4. #3
    Join Date
    Dec 2016
    Posts
    26
    Thanks
    14
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: setting an image backround(using qwt multi-axis)

    thanks Uwe,
    type of format can be .png or .bmp or .jpeg that there is no problem for converting to a format that qwt multi-axis needs
    its a simple image of a dem(by print screen of a dem)
    the image relates to the plot axis by converting latitude and longtude to (x,y), knowing two point

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

    Default Re: setting an image backround(using qwt multi-axis)

    For SVGs there is an plot item, but for raster data images you have to implement your own. Simply derive from QwtPlotItem and use QPainter::drawPixmap in YourPlotItem::draw.
    If you have the option of using vector graphics ( not embedding raster graphics into a SVG ), this would be preferable as you can zoom in/out then.

    Uwe

  6. The following user says thank you to Uwe for this useful post:

    QJak (7th February 2019)

  7. #5
    Join Date
    Dec 2016
    Posts
    26
    Thanks
    14
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: setting an image backround(using qwt multi-axis)

    thanks. I can use SVGs. can you explain more about plot item about svg please?

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

    Default Re: setting an image backround(using qwt multi-axis)

    https://qwt.sourceforge.io/class_qwt_plot_svg_item.html
    Try the playground/svgmap example.

  9. The following user says thank you to Uwe for this useful post:

    QJak (7th February 2019)

  10. #7
    Join Date
    Dec 2016
    Posts
    26
    Thanks
    14
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: setting an image backround(using qwt multi-axis)

    so.many thanks. does qwt multiaxis support this? my project is on qwt multiaxis.

  11. #8
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,141
    Thanked 824 Times in 773 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: setting an image backround(using qwt multi-axis)

    Quote Originally Posted by QJak View Post
    so.many thanks. does qwt multiaxis support this? my project is on qwt multiaxis.
    Sure, why not ?

  12. The following user says thank you to Uwe for this useful post:

    QJak (7th February 2019)

  13. #9
    Join Date
    Dec 2016
    Posts
    26
    Thanks
    14
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: setting an image backround(using qwt multi-axis)

    so many thanks. it works but there is a problem
    for the image.svg that i uploaded, showing is not true. the scale is: (0, 0, 9.513, 6.886). also i uploaded the screenshot of showing image.svg by "svgmap" example in "playground"
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by QJak; 8th February 2019 at 13:13.

  14. #10
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,141
    Thanked 824 Times in 773 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: setting an image backround(using qwt multi-axis)

    The SVG item tries to scale the content of the image according to its view box. When looking at the SVG it looks like the viewBox is a ~QRect( 9, 45, 9, 6 ), while I can see that other SVGs, that work as expected have a viewBox starting at 0, 0. So that might be a bug, that is related to this - I will have a look at it.

    But a SVG can be translated easily into a QwtGraphic, so it makes sense to have a QwtPlotGraphicItem, that covers a lot more use cases and QwtPlotSvgItem could be removed then. Guess I will do this next time I'm working on the code.

    As a side note: if your SVG image consists of these borders only it makes more sense to use one or several QPainterPaths instead of the SVG. A QPainterPath can be displayed as a QwtPlotShapeItem. The advantage of using a QPainterPath is, that you can set the colors, pen widths and filling, so that they fit to the background. When the boundaries are split into several painter paths you can also show/hide them Individually.

    Uwe

  15. The following user says thank you to Uwe for this useful post:

    QJak (11th February 2019)

Similar Threads

  1. Problems setting a background image
    By franco.amato in forum Qt Programming
    Replies: 10
    Last Post: 28th January 2011, 23:33
  2. setting an image on the form
    By Yayati.Ekbote in forum Newbie
    Replies: 6
    Last Post: 15th March 2010, 12:39
  3. Replies: 0
    Last Post: 25th February 2009, 08:15
  4. setting an image.jpg in a QWidget
    By impeteperry in forum Qt Programming
    Replies: 1
    Last Post: 6th February 2009, 20:00
  5. Setting background image of QFrame
    By Claymore in forum Qt Programming
    Replies: 2
    Last Post: 12th February 2007, 20:50

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.