Results 1 to 6 of 6

Thread: Spacing around legend items

  1. #1
    Join Date
    Feb 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Spacing around legend items

    I'm using a legend on the left side of the plot and the left and right margins around the legend items are too big. How can I make them smaller?

    I need to make them as small as possible as I don't have much space.
    I already tried:

    legend->contentsWidget()->layout()->setSpacing(0);
    legend->contentsWidget()->layout()->setContentsMargins(0,0,0,0);

    And it does decrease the spacing between legend items but not the left and right margin.

    I don't know if this makes a difference but the legend has so many legend items that it has a vertical scrool bar.

    Thanks for the help,
    Filipe

  2. #2
    Join Date
    Feb 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Spacing around legend items

    I've now realized the problem is related to the fact that my legend items have newlines in their name. I think this confuses the size calculation in QwtTextEngine.
    Is there a reason not to have QwtTextLabel inherit from QLabel? It would make this kind of problems go away I think.

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

    Default Re: Spacing around legend items

    It would make your text go away, because QLabel can't display a QwtText.

    Look at the simple example and play with the curve titles. If you find a title, where you think, that the layout calculation is wrong tell us about it and post a screenshot.

    Uwe

    PS: Some basic infos ( OS, Qt/Qwt versions, which font, rich- or plain Text, which curve title ...) would be more helpful than posting speculations.

  4. #4
    Join Date
    Feb 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Spacing around legend items

    The problem seems to be totally unrelated to the newlines. It seems to happen when the scrollbar show up. Probably it's just some spacing i forgot to set to 0.

    I altered the simple_plot example to add a bunch of extra curves:

    cCos = new QwtPlotCurve("5678");
    cCos->attach(this);
    cCos = new QwtPlotCurve("5678");
    cCos->attach(this);
    cCos = new QwtPlotCurve("5678");
    cCos->attach(this);
    ...

    In the attached image you can see what happens when I resize the simple_plot so that the scrollbar shows up. The legend gets padded on the sides with whitespace. I would like it to stay as tightly packed as it is without the scrollbar.

    OS is MacOSX Qwt 5.1.1 Qt 4.4

    Thanks,
    Filipe
    Attached Images Attached Images

  5. #5
    Join Date
    Feb 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Spacing around legend items

    The bug is in QwtLegend::verticalScrollBar() qwt_legend.cpp:367

    The current code has return d_data->view->horizontalScrollBar();
    instead of return d_data->view->verticalScrollBar();

    This fixes my problem.

  6. #6
    Join Date
    Jul 2015
    Posts
    22
    Thanks
    23
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Spacing around legend items

    Hello everyone. I have a similar problem. I have a right legend and I need to place all legend items evenly at the space right from the canvas. legend->contentsWidget()->layout()->setSpacing can resolve this task, but problem is I always have different amount of curves, so trying to resolve this task in that way seems inadequate. Is there any Qwt's built-in methods for doing this?

    Thanks in advance.

Similar Threads

  1. Some menubar items can not be clicked
    By richardander in forum Qt Programming
    Replies: 4
    Last Post: 11th March 2009, 01:26
  2. Remove Legend items, move legends
    By giusepped in forum Qwt
    Replies: 0
    Last Post: 11th February 2009, 03:35
  3. strange extra spacing between checkboxes
    By jamadagni in forum Qt Programming
    Replies: 1
    Last Post: 19th November 2007, 11:13
  4. Light items for the graphicsView
    By maverick_pol in forum Qt Programming
    Replies: 12
    Last Post: 1st November 2007, 19:51
  5. Selective highlighting of Items
    By Kapil in forum Qt Programming
    Replies: 3
    Last Post: 26th May 2006, 13:20

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.