Last summer, while we were finishing up 4.2, there was a great deal of activity on the mailing lists we set up for the 4.2 technical preview (http://lists.trolltech.com/). Some people kept on asking for support for "untransformable" items, that is, special QGraphicsItem items that don't follow the parent's or view's transformations. Like the text labels in Google Earth, they stay horizontal when you rotate, and don't change their size when you zoom.
Because of the risk of destabilizing the base behavior, we decided to postpone such a feature, and it was moved into research.
Good news, it looks like we will be adding this feature to 4.3. It's still in research, but working quite well. There are some minor details to iron out, but mostly under the hood and they will not affect the API or behavior in any way.
To trigger this special behavior, you set a flag: ItemIgnoresViewTransformations (, or something like that). Then you can add the item as a regular child of another item. Its position will then show where the item is "anchored" to its parent. And the item is rendered without any rotation or scaling imposed by the view. For example:
QLinearGradient gradient(-100, -100, 0, 100);
gradient.setColorAt(0, QColor(128, 255, 192));
gradient.setColorAt(1, QColor(63, 255, 63));
// Create a scene, add the main ellipse.
= scene.addEllipse(QRectF(-100, -100, 200, 200),
QPen(Qt::black, 2), gradient);
// Add two child lines that cross over the ellipse.
QGraphicsLineItem *line1 = new QGraphicsLineItem(-100, 0, 100, 0, ellipse);
QGraphicsLineItem *line2 = new QGraphicsLineItem(0, -100, 0, 100, ellipse);
// Add five _untransformable_ text items around the ellipse.
for (int i = 0; i setParentItem(ellipse);
text->setPos(100 * cos((6.28 * i) / 5.0), 100 * sin((6.28 * i) / 5.0));
The items still follow regular items' rendering constraints (e.g., the stacking order is the same as with normal items). You can also rotate or scale the item itself; that still works. It just doesn't inherit any transformations.
PS: The Hell Wyrm has been defeated! It took me a good 1.5 hrs of continuous struggle to nail this mark. Can you believe that it's got 6 million HP?? ;-)
Download the latest release here: www.qt.io/download.
Qt 5.12 was developed with a strong focus on quality and is a long-term-supported (LTS) release that will be supported for 3 years.
Check out all our open positions here and follow us on Instagram to see what it's like to be #QtPeople.
Näytä tämä julkaisu Instagramissa.
Want to build something for tomorrow, join #QtPeople today! We have loads of cool jobs you don’t want to miss! http://qt.io/careers #builtwithQt #software #developers #coding #framework #tool #tooling #C++ #QML #engineers #sales #tech #technology #UI #UX #CX #Qt #Qtdev #global #openpositions #careers #job
Henkilön Qt (@theqtcompany) jakama julkaisu