! \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
| 12460 | \see createAnchor |
| 12461 | */ |
| 12462 | QCPItemPosition *QCPAbstractItem::createPosition(const QString &name) |
| 12463 | { |
| 12464 | if (hasAnchor(name)) |
| 12465 | qDebug() << Q_FUNC_INFO << "anchor/position with name exists already:" << name; |
| 12466 | QCPItemPosition *newPosition = new QCPItemPosition(mParentPlot, this, name); |
| 12467 | mPositions.append(newPosition); |
| 12468 | mAnchors.append(newPosition); // every position is also an anchor |
| 12469 | newPosition->setAxes(mParentPlot->xAxis, mParentPlot->yAxis); |
| 12470 | newPosition->setType(QCPItemPosition::ptPlotCoords); |
| 12471 | if (mParentPlot->axisRect()) |
| 12472 | newPosition->setAxisRect(mParentPlot->axisRect()); |
| 12473 | newPosition->setCoords(0, 0); |
| 12474 | return newPosition; |
| 12475 | } |
| 12476 | |
| 12477 | /*! \internal |
| 12478 |