[Interest] Qt Charts: Making the legend top and right aligned

Christopher Probst christop.probst at gmail.com
Wed Apr 11 16:39:27 CEST 2018


 A solution would be doing something like this:

m_chart->legend()->setAlignment(Qt::AlignTop);

QApplication::processEvents();

m_chart->legend()->setY(m_chart->plotArea().height() - m_chartView->height() );


Which feels like a big hack. Is there a better way? There must be.



On 11 April 2018 at 10:12, Christopher Probst <christop.probst at gmail.com>
wrote:

> Ok there seems to be a solution to this by Using
>
>
> m_chart->legend()->moveBy
>
>
> I will keep you posted.
>
>
> On 11 April 2018 at 10:05, Christopher Probst <christop.probst at gmail.com>
> wrote:
>
>> I have noticed that! Clearly they thought of it! I tried grabbing the y
>> coordinate of the legend and changing it. That also does not work! It would
>> be nice to have a solution to this.
>>
>> On 11 April 2018 at 10:03, Mike Chinander <chinander at gmail.com> wrote:
>>
>>> Not sure of a solution to this, but noticed that unlike other uses of
>>> Qt::Alignment flags, the QLegend docs say, "If you set more than one flag,
>>> the result is undefined."
>>>
>>> https://doc.qt.io/qt-5.10/qlegend.html#alignment-prop
>>>
>>> On Wed, Apr 11, 2018 at 8:51 AM, Christopher Probst <
>>> christop.probst at gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> I would like to place the legend of  chart that uses Qt charts at the
>>>> top right of the view. I would have expected something like this to work:
>>>>
>>>>  m_chart->legend()->setAlignment(Qt::AlignTop| Qt::AlignRight)
>>>>
>>>>
>>>> Unfortunately it does not! Is there a direct way to  make the legends (right or left) be top aligned rather then middle.?
>>>>
>>>>
>>>> Thanks,
>>>>
>>>> Christopher
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Interest mailing list
>>>> Interest at qt-project.org
>>>> http://lists.qt-project.org/mailman/listinfo/interest
>>>>
>>>>
>>>
>>> _______________________________________________
>>> Interest mailing list
>>> Interest at qt-project.org
>>> http://lists.qt-project.org/mailman/listinfo/interest
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180411/03717c70/attachment.html>


More information about the Interest mailing list