Results 1 to 2 of 2

Thread: unable to set border for canvas in qwt

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

    Default unable to set border for canvas in qwt

    Hi friends/experts,

    im using Qt.5.7 and qwt version 6.1.2

    i tired to initialize qwt plot by following

    Qt Code:
    1. QwtPlotLayout *pLayout = plotLayout();
    2. pLayout->setCanvasMargin(0);
    3. pLayout->setAlignCanvasToScales (true);
    4.  
    5.  
    6. //Canvas setup
    7. m_pCanvas = new QwtPlotCanvas();
    8. m_pCanvas->setFrameStyle( QFrame::Box | QFrame::Plain );
    9. m_pCanvas->setLineWidth( 1);
    10.  
    11. m_pCanvas->setContentsMargins(0,0,0,0);
    12. m_pCanvas->setPaintAttribute(QwtPlotCanvas::BackingStore, false);
    13. m_pCanvas->setPaintAttribute(QwtPlotCanvas::Opaque, false);
    14. m_pCanvas->setAttribute( Qt::WA_OpaquePaintEvent, false );
    15.  
    16.  
    17. m_pCanvas->setAutoFillBackground( false);
    18.  
    19. QColor background = QColor(QColor(255,255,255));
    20. background.setAlpha(255);
    21.  
    22. QPalette palette;
    23. palette.setColor(QPalette::Window, background);
    24. setPalette(palette);
    25.  
    26. setCanvasBackground (background);
    27. setAttribute(Qt::WA_TranslucentBackground);
    28.  
    29.  
    30. setCanvas( m_pCanvas );
    To copy to clipboard, switch view to plain text mode 

    but line width or border of canvas is not visible at all.

    i tired setting canvas color

    as
    QPalette p = palette();
    p.setColor(QPalette::Window, color);

    canvas()->setPalette(p);
    canvas()->setAutoFillBackground(true);

    but canvas color is not reflecting in the plot.

    please help me and suggest me some solution. same was working in qt.4.7
    "Behind every great fortune lies a crime" - Balzac

  2. #2
    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: unable to set border for canvas in qwt

    This line kills the border:
    Quote Originally Posted by wagmare View Post
    m_pCanvas->setContentsMargins(0,0,0,0);
    In earlier Qt versions only QFrame had a contentsRect and the margins were the frame width. This has been changed with Qt4, leaving frames having this odd relationship to the margins.

    Uwe

Similar Threads

  1. How to get Canvas
    By mqt in forum Qwt
    Replies: 2
    Last Post: 21st May 2015, 13:14
  2. Replies: 10
    Last Post: 9th September 2013, 15:29
  3. Replies: 2
    Last Post: 21st March 2012, 14:30
  4. Replies: 1
    Last Post: 12th November 2011, 10:11
  5. qwt canvas border
    By stefan in forum Qwt
    Replies: 1
    Last Post: 7th March 2011, 16:10

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.