Results 1 to 4 of 4

Thread: How to set BackGround Image for the plot

  1. #1
    Join Date
    Oct 2008
    Posts
    10
    Thanks
    1

    Default How to set BackGround Image for the plot

    Is there a way to set a background image for my plot.
    I'm preparing a demo version for my program , and I want to write "Demo Version" at the background of the plot.
    If setting a background image is not possible ( which I couldn't find) , is there something else I can do?
    Thanks for any kinds of help

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

    Default Re: How to set BackGround Image for the plot

    You can assign a brush with an image to the palette of the canvas, but better implement a small plot item for your background text:

    Qt Code:
    1. class Watermark: public QwtPlotItem
    2. {
    3. public:
    4. Watermark()
    5. {
    6. setZ(0.0);
    7. }
    8.  
    9. virtual int rtti() const
    10. {
    11. return QwtPlotItem::Rtti_PlotUserItem + 123;
    12. }
    13.  
    14. virtual void draw(QPainter *painter,
    15. const QwtScaleMap &, const QwtScaleMap &,
    16. const QRect &rect) const
    17. {
    18. QwtPainter::fillRect(painter, rect, ...);
    19. QwtPainter::drawText(painter, rect, ...);
    20. }
    21. };
    To copy to clipboard, switch view to plain text mode 

    Uwe

  3. #3
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to set BackGround Image for the plot

    QPixmap pixmap("jughead-jones_large.png");
    QWidget w;
    QPalette p = w.palette();
    p.setBrush(QPalette::Base, pixmap);
    w.setPalette(p);
    "Behind every great fortune lies a crime" - Balzac

  4. #4
    Join Date
    Aug 2009
    Posts
    56
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Re: How to set BackGround Image for the plot

    Quote Originally Posted by Uwe View Post
    You can assign a brush with an image to the palette of the canvas, but better implement a small plot item for your background text:

    Qt Code:
    1. class Watermark: public QwtPlotItem
    2. {
    3. public:
    4. Watermark()
    5. {
    6. setZ(0.0);
    7. }
    8.  
    9. virtual int rtti() const
    10. {
    11. return QwtPlotItem::Rtti_PlotUserItem + 123;
    12. }
    13.  
    14. virtual void draw(QPainter *painter,
    15. const QwtScaleMap &, const QwtScaleMap &,
    16. const QRect &rect) const
    17. {
    18. QwtPainter::fillRect(painter, rect, ...);
    19. QwtPainter::drawText(painter, rect, ...);
    20. }
    21. };
    To copy to clipboard, switch view to plain text mode 

    Uwe
    This works, but the texture tiles. How can I get it to stretch instead of tile?

Similar Threads

  1. Replies: 10
    Last Post: 10th November 2010, 03:12
  2. Replies: 2
    Last Post: 30th June 2009, 17:08
  3. Saving pure plot data to image file
    By Debilski in forum Qwt
    Replies: 4
    Last Post: 7th April 2009, 17:02
  4. QCalendarWidget background image
    By khcbabu in forum Newbie
    Replies: 0
    Last Post: 31st March 2009, 12:51
  5. How to stretch background image used in brush-palette
    By Hookem in forum Qt Programming
    Replies: 5
    Last Post: 24th December 2008, 17:03

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.