Results 1 to 5 of 5

Thread: Set a picture for the background

  1. #1
    Join Date
    Feb 2011
    Location
    Nizhny Novgorod, Russian Federation
    Posts
    7
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Set a picture for the background

    Hello everyone,

    I novice qwt user and the problem is following
    I represented the city map using qwt and I represented some points on the map (for example, bus stops).

    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?

    Thanks a lot in advance!

  2. #2
    Join Date
    Oct 2010
    Location
    Tanzania
    Posts
    6
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Set a picture for the background

    Quote Originally Posted by Roman Novoselov View Post
    Hello everyone,

    I novice qwt user and the problem is following
    I represented the city map using qwt and I represented some points on the map (for example, bus stops).

    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?

    Thanks a lot in advance!
    to set picture, u should insert Qlabel and add your picture under 'pixmap' property or use that property for ur any pixmap supprting wedget(may b wedget u used as bg).
    -Al-Mazeedy

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

    Default Re: Set a picture for the background

    Quote Originally Posted by Roman Novoselov View Post
    I want to set the real city's map image to the background of the plot.
    The data displayed on the plot canvas is related to the scales. For an areal photo ( or other images ) this always means some sort of resampling. How to do this depends on your particular situation.

    The plot item for displaying raster data ( data that is mapped somehow to an image ) is QwtPlotRasterItem. You need to derive from this class and implement:
    Qt Code:
    1. virtual QImage YourRasterItem::renderImage(
    2. const QwtScaleMap &xMap,
    3. const QwtScaleMap &yMap,
    4. const QwtDoubleRect &area
    5. ) const;
    To copy to clipboard, switch view to plain text mode 

    Uwe

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

    Roman Novoselov (17th March 2011)

  5. #4
    Join Date
    Feb 2011
    Location
    Nizhny Novgorod, Russian Federation
    Posts
    7
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Set a picture for the background

    Thanks Uwe,

    I have the following:
    class RasterItem: public QwtPlotRasterItem
    {
    ...
    private:
    QImage renderImage (const QwtScaleMap & xMap, const QwtScaleMap & yMap, const QwtDoubleRect & area) const;
    };

    QImage RasterItem::renderImage (const QwtScaleMap & xMap, const QwtScaleMap & yMap, const QwtDoubleRect & area) const
    {
    if (area.isEmpty ())
    return QImage ();

    QRect rect = transform (xMap, yMap, area);
    QPixmap pixmap (rect.width(), rect.height());
    pixmap.load (filename);
    return pixmap.convertToImage ();
    }
    class Plot : public QwtPlot
    {
    ...
    };

    Plot::Plot(QWidget *parent)
    {
    ...
    RasterItem * image = new RasterItem (QString ("Title"));
    ...
    }
    Which method of QwtPlot should I use for drawing an image?


    Added after 27 minutes:


    Thanks all,
    I found the method, if it is need somebody else:
    image->attach (this);

    It remains to solve the problem with zoom
    When I change zoom of the city map, curves are changes, but the image of city stays the same size
    Last edited by Roman Novoselov; 17th March 2011 at 09:12.

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

    ziXet (10th February 2012)

  7. #5
    Join Date
    Feb 2010
    Posts
    7
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Set a picture for the background

    Quote Originally Posted by Roman Novoselov View Post
    Thanks Uwe,

    I have the following:




    Which method of QwtPlot should I use for drawing an image?


    Added after 27 minutes:


    Thanks all,
    I found the method, if it is need somebody else:



    It remains to solve the problem with zoom
    When I change zoom of the city map, curves are changes, but the image of city stays the same size
    Can you put your complete RasterItem class code here?

Similar Threads

  1. How to change QComboBox background with a picture?
    By mulei in forum Qt Programming
    Replies: 3
    Last Post: 24th September 2010, 07:59
  2. Replies: 2
    Last Post: 29th March 2010, 15:43
  3. can't load picture
    By aoo7wangyan in forum Qt Programming
    Replies: 9
    Last Post: 13th July 2009, 14:59
  4. resize a picture
    By omega36 in forum Qt Programming
    Replies: 2
    Last Post: 9th January 2009, 14:34
  5. Replies: 1
    Last Post: 24th August 2007, 11:18

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.