Login

Grabbing all QGraphicItems current viewable in a QGraphicView

The best way to get a list of all items current displayed inside the QGraphicsView is done through the combination of three steps: get viewing rectangle get items intersecting or inside rectangle check for visibility 1 2 3 4 5 6 7 QList<QGraphicsItem* > viewItems = m_pView->items(m_pView->rect());   for(int i=0; i < viewItems.size(); ++i) { if(viewItems.at(i)->isVisible()) { //payload } } Do not use other rectangle functions like sceneRect(), childrenRect(), contentsRect(), etc… as they [...] [Read full arcticle]
Posted in Qt Code | Tagged , , , | Leave a comment

Qt mousePressEvent and mouseReleaseEvent fun!

This would have been good to know beforehand regarding mouse events… Apparently in Qt, QGraphicsItem’s mouse events are a little different from the model I had in my head from Actionscript. In actionscript when a user uses the mouse to move over and then click on an MovieClip object these events occur (ignoring mouse movement events): onRollOver onPress onRelease onRollOut In [...] [Read full arcticle]
Posted in Qt Code | Tagged , , , | Leave a comment

Making a QPixmap transparent the Right Way

The Problem The classic situation that this problem can occur is when one wants to create a QPixmap with a transparent background and then draws on only some of the available pixels. This process is akin to creating a transparent GIF. Well there is a wrong way and a right way. I discovered this because I [...] [Read full arcticle]
Posted in Qt Code | Tagged , , , | Leave a comment