Russian Qt Forum

Qt => Model-View (MV) => Тема начата: Caduceus от Сентябрь 20, 2010, 22:36



Название: QGraphicsScene - элементы не в том порядке как добавлял
Отправлено: Caduceus от Сентябрь 20, 2010, 22:36
Добавляю элементы в QGraphicsScene в строгой последовательности. Мне так и нужно, чтобы они шли. Но при прохождении потом списка элементов сцены первый вдруг оказался последним, и видимо все так наоборот. Никакх сортировок не включал. Они включены по-умолчанию? Как их вырубить, если да. А если нет - почему список объектов не такой как при создании?


Название: Re: QGraphicsScene - элементы не в том порядке как добавлял
Отправлено: noirhor от Сентябрь 20, 2010, 23:40
Цитировать
QList<QGraphicsItem *> QGraphicsScene::items ( Qt::SortOrder order ) const
То?


Название: Re: QGraphicsScene - элементы не в том порядке как добавлял
Отправлено: mal от Сентябрь 23, 2010, 18:04
Цитировать
QGraphicsItem Class Reference
...
Sorting
All items are drawn in a defined, stable order, and this same order decides which items will receive mouse input first when you click on the scene. Normally you don't have to worry about sorting, as the items follow a "natural order", following the logical structure of the scene.
An item's children are stacked on top of the parent, and sibling items are stacked by insertion order (i.e., in the same order that they were either added to the scene, or added to the same parent). If you add item A, and then B, then B will be on top of A. If you then add C, the items' stacking order will be A, then B, then C.

если нужен иной порядок юзаем void QGraphicsItem::setZValue ( qreal z )