Results 1 to 5 of 5

Thread: How to get same icon size in QwtLegendItem for each entry? (fixed width)

  1. #1
    Join Date
    Jul 2015
    Posts
    87
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default How to get same icon size in QwtLegendItem for each entry? (fixed width)

    Hello,

    i have a QwtLegendItem that shows attached Plots
    and attached QwtPlotShapeItems. The have all different
    width of the icon left of theier name in QwtLegendItem.

    SizeOfIconsInQwtLegendItem.png

    How can i realize, that all have the same icon (symbol) width in QwtLegendItem?

    Thx

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

    Default Re: How to get same icon size in QwtLegendItem for each entry? (fixed width)

    What about using: shapeItem->setLegendIconSize( ... ) ?

    Uwe

  3. #3
    Join Date
    Jul 2015
    Posts
    87
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to get same icon size in QwtLegendItem for each entry? (fixed width)

    I do that already for the shapeItem with QSize(18x10). The problem ist not the shapeItem,
    the problems are the curveItems.
    I tried that also for curveItem with no effect, the LegendIconSize of a curve doesn'nt change.
    A curve without symbol has a small legendItcon and a curve with symbol has a much bigger symbol in width.
    That is shown in the picture.

    Stefan

    PS: the main problem for curveItem is qwtUpdateLegendIconSize, that is a static method in QwtPlotCurve and can't be override.
    Last edited by HappyCoder; 7th March 2016 at 11:51.

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

    Default Re: How to get same icon size in QwtLegendItem for each entry? (fixed width)

    PS: the main problem for curveItem is qwtUpdateLegendIconSize, that is a static method in QwtPlotCurve and can't be override.
    Qt Code:
    1. class YourCurve: public QwtPlotCurve
    2. {
    3. ...
    4. virtual QwtGraphic legendIcon( int index, const QSizeF &size ) const
    5. {
    6. QSizeF extendedSize;
    7. extendedSize.setHeight( size.height() );
    8. extendedSize.setWidth( ... );
    9.  
    10. return QwtPlotCurve::legendIcon( index, extendedSize );
    11. }
    12. };
    To copy to clipboard, switch view to plain text mode 
    Uwe

  5. #5
    Join Date
    Jul 2015
    Posts
    87
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Thumbs up Re: How to get same icon size in QwtLegendItem for each entry? (fixed width)

    Excellent Uwe !!! Exactly what i was looking for.
    Thank You!

Similar Threads

  1. Replies: 0
    Last Post: 30th November 2015, 16:48
  2. QListWidget width always fixed to 256
    By Suppaman in forum Qt Programming
    Replies: 2
    Last Post: 9th May 2013, 22:19
  3. Replies: 0
    Last Post: 14th February 2012, 15:43
  4. Replies: 4
    Last Post: 20th November 2009, 12:25
  5. QToolBox width fixed to maximum content width
    By ghorwin in forum Qt Programming
    Replies: 0
    Last Post: 10th July 2009, 09:58

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.