本文整理汇总了C++中ImageView::layoutProperties方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageView::layoutProperties方法的具体用法?C++ ImageView::layoutProperties怎么用?C++ ImageView::layoutProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageView
的用法示例。
在下文中一共展示了ImageView::layoutProperties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parentHeightChanged
void Map::parentHeightChanged(float parentHeight)
{
const float padding = 10; // Padding of at least 10 on all sides.
parentHeight = parentHeight - padding*2;
const float cellWidth = m_mapWidth / m_cols;
const float cellHeight = parentHeight / m_rows;
float oldCellSize = m_cellSize;
m_cellSize = std::min(cellWidth, cellHeight);
m_mapArea->setPreferredSize(m_cellSize * m_cols, m_cellSize * m_rows);
QObjectList list = m_mapArea->children();
if (m_rows * m_cols + 1 != list.count()) { qDebug("Uhoh: List size not correct!"); }
int i=0;
for (int y=0; y<m_rows; y++) {
for (int x=0; x<m_cols; x++) {
ImageView *cell = qobject_cast<ImageView*>(list[i]);
if (cell) {
cell->setPreferredSize(m_cellSize, m_cellSize);
AbsoluteLayoutProperties *properties = static_cast<AbsoluteLayoutProperties*>(cell->layoutProperties());
properties->setPositionX(x * m_cellSize);
properties->setPositionY(y * m_cellSize);
}
i++;
}
}
Container *robot = qobject_cast<Container*>(list[i]);
if (robot) {
robot->setPreferredSize(m_cellSize, m_cellSize);
AbsoluteLayoutProperties *properties = static_cast<AbsoluteLayoutProperties*>(robot->layoutProperties());
properties->setPositionX(properties->positionX() * m_cellSize / oldCellSize);
properties->setPositionY(properties->positionY() * m_cellSize / oldCellSize);
}
}