本文整理汇总了C++中TileLayer::getCellAt方法的典型用法代码示例。如果您正苦于以下问题:C++ TileLayer::getCellAt方法的具体用法?C++ TileLayer::getCellAt怎么用?C++ TileLayer::getCellAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TileLayer
的用法示例。
在下文中一共展示了TileLayer::getCellAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mousePressed
void CellPropertiesTool::mousePressed(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
TileLayer *tileLayer = currentTileLayer();
Q_ASSERT(tileLayer);
const QPoint tilePos = tilePosition();
Cell *cell = tileLayer->getCellAt(tilePos.x(),tilePos.y());
// Add properties from tile
if (!cell->isEmpty() ) {
Properties properties = cell->properties();
Properties tileprop = tileLayer->cellAt(tilePos.x(),tilePos.y()).tile->properties();
QStringList req = tileprop.value(QString::fromLatin1("required")).split(QString::fromLatin1(","));
req << tileprop.value(QString::fromLatin1("optional")).split(QString::fromLatin1(","));
foreach (const QString &str, req) {
int p = str.indexOf(QString::fromLatin1("="));
QString key, value(QString::fromLatin1(""));
if (0==p) {
// only name
key = str.trimmed();
} else {
key = str.left(p).trimmed();
value = str.right(str.length() - p - 1);
// options = value.split("/");
}
if (key.isEmpty())
continue;
// Keep the key if exist, otherwise insert the new value (empty by default)
if (!properties.contains(key))
properties.insert(key, value);
}