! \internal Creates a QCPItemPosition, registers it with this item and returns a pointer to it. The specified \a name must be a unique string that is usually identical to the variable name of the position member (This is needed to provide the name-based \ref position access to positions). Don't delete positions created by this function manually, as the item will take care of it. U
| 12471 | \see createAnchor |
| 12472 | */ |
| 12473 | QCPItemPosition *QCPAbstractItem::createPosition(const QString &name) |
| 12474 | { |
| 12475 | if (hasAnchor(name)) |
| 12476 | qDebug() << Q_FUNC_INFO << "anchor/position with name exists already:" << name; |
| 12477 | QCPItemPosition *newPosition = new QCPItemPosition(mParentPlot, this, name); |
| 12478 | mPositions.append(newPosition); |
| 12479 | mAnchors.append(newPosition); // every position is also an anchor |
| 12480 | newPosition->setAxes(mParentPlot->xAxis, mParentPlot->yAxis); |
| 12481 | newPosition->setType(QCPItemPosition::ptPlotCoords); |
| 12482 | if (mParentPlot->axisRect()) |
| 12483 | newPosition->setAxisRect(mParentPlot->axisRect()); |
| 12484 | newPosition->setCoords(0, 0); |
| 12485 | return newPosition; |
| 12486 | } |
| 12487 | |
| 12488 | /*! \internal |
| 12489 |