@@ -77,6 +77,8 void MainWidget::detachLegend() | |||||
77 | // Detach legend from chart |
|
77 | // Detach legend from chart | |
78 | QLegend *legend = m_chart->legend(); |
|
78 | QLegend *legend = m_chart->legend(); | |
79 | legend->detachFromChart(); |
|
79 | legend->detachFromChart(); | |
|
80 | legend->setGeometry(m_customView->rect()); | |||
|
81 | // legend->setAlignment(QLegend::AlignmentLeft); | |||
80 |
|
82 | |||
81 | // Put legend to our custom scene |
|
83 | // Put legend to our custom scene | |
82 | m_customScene->addItem(legend); |
|
84 | m_customScene->addItem(legend); | |
@@ -100,6 +102,7 void MainWidget::attachLegend() | |||||
100 | m_customScene->removeItem(legend); |
|
102 | m_customScene->removeItem(legend); | |
101 | legend->setParent(m_chart); |
|
103 | legend->setParent(m_chart); | |
102 | m_chartView->scene()->addItem(legend); |
|
104 | m_chartView->scene()->addItem(legend); | |
|
105 | // legend->setAlignment(QLegend::AlignmentBottom); | |||
103 | legend->attachToChart(); |
|
106 | legend->attachToChart(); | |
104 | } |
|
107 | } | |
105 | //![4] |
|
108 | //![4] |
@@ -173,7 +173,7 QPen QLegend::pen() const | |||||
173 | */ |
|
173 | */ | |
174 | void QLegend::setAlignment(QLegend::Alignments alignment) |
|
174 | void QLegend::setAlignment(QLegend::Alignments alignment) | |
175 | { |
|
175 | { | |
176 |
if(d_ptr->m_alignment!=alignment |
|
176 | if(d_ptr->m_alignment!=alignment) { | |
177 | d_ptr->m_alignment = alignment; |
|
177 | d_ptr->m_alignment = alignment; | |
178 | d_ptr->updateLayout(); |
|
178 | d_ptr->updateLayout(); | |
179 | } |
|
179 | } | |
@@ -402,8 +402,10 void QLegendPrivate::updateLayout() | |||||
402 | break; |
|
402 | break; | |
403 | } |
|
403 | } | |
404 |
|
404 | |||
|
405 | if (m_attachedToChart) { | |||
405 | m_presenter->updateLayout(); |
|
406 | m_presenter->updateLayout(); | |
406 | } |
|
407 | } | |
|
408 | } | |||
407 |
|
409 | |||
408 | void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain) |
|
410 | void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain) | |
409 | { |
|
411 | { |
General Comments 0
You need to be logged in to leave comments.
Login now