! Returns the legends that currently have selected parts, i.e. whose selection state is not \ref QCPLegend::spNone. \see selectedPlottables, selectedAxes, setInteractions, QCPLegend::setSelectedParts, QCPLegend::setSelectableParts, QCPLegend::selectedItems */
| 14324 | QCPLegend::setSelectableParts, QCPLegend::selectedItems |
| 14325 | */ |
| 14326 | QList<QCPLegend*> QCustomPlot::selectedLegends() const |
| 14327 | { |
| 14328 | QList<QCPLegend*> result; |
| 14329 | |
| 14330 | QStack<QCPLayoutElement*> elementStack; |
| 14331 | if (mPlotLayout) |
| 14332 | elementStack.push(mPlotLayout); |
| 14333 | |
| 14334 | while (!elementStack.isEmpty()) |
| 14335 | { |
| 14336 | Q_FOREACH (QCPLayoutElement *subElement, elementStack.pop()->elements(false)) |
| 14337 | { |
| 14338 | if (subElement) |
| 14339 | { |
| 14340 | elementStack.push(subElement); |
| 14341 | if (QCPLegend *leg = qobject_cast<QCPLegend*>(subElement)) |
| 14342 | { |
| 14343 | if (leg->selectedParts() != QCPLegend::spNone) |
| 14344 | result.append(leg); |
| 14345 | } |
| 14346 | } |
| 14347 | } |
| 14348 | } |
| 14349 | |
| 14350 | return result; |
| 14351 | } |
| 14352 | |
| 14353 | /*! |
| 14354 | Deselects all layerables (plottables, items, axes, legends,...) of the QCustomPlot. |