Widgets On The Canvas Integrated

Posted by Andreas Aardal Hanssen on November 22, 2007 · 16 comments

The day has finally arrived. We are proud to announce that we have now integrated our development branch for the Widgets On The Canvas project into Qt/main, or what will become Qt 4.4. You have already seen a random selection of screenshots and feature rundowns in previous blogs, but now it’s all in your hands to try and enjoy. It should appear in tonight’s snapshots.

I’d like to thank Jan-Arve, Bjørn Erik, Jo, Benjamin, Jasmin, Girish, Lars, and everyone else who has helped us with rowing this boat ashore. It was a beast, but we seem to have managed to tame it. Now, we’d all like for you to play around with this API, and let us know what you think.

Graphics View now provides a brand new layout and widget API. It’s similar to the way QWidget works, and should be familiar for most of you right away. The purpose of this API is mainly so you can write layout-aware items, but it also means you now have a richer base class for your items. Because QGraphicsWidget inherits from QObject, it allows declaring signals and slots and manages event delivery just like any widget in Qt. Like QWidget it also provides a palette, a font, layout directions and a style.

Graphics View doesn’t provide its own widgets like QLineEdit and QComboBox – instead, you can embed existing widgets (indeed, any custom widget that you have written yourself) into the scene by calling QGraphicsScene::addWidget(). If you also pass the Qt::Window flag, your widgets will even get window decorations similar to QMdiSubWindow. You can move, resize, rotate and scale your widgets, or combine widgets and items to generate fancy overlay or transition effects.

There are still a few remaining issues to solve. For one, Graphics View automatically embeds popups of embedded widgets. So if you embed a combobox, its popup will also appear as an embedded popup inside the scene. And QMenuBar’s menus also also embedded. We aim to make this feature work 100% for 4.4, but currently it doesn’t work properly (in particular, modality and mouse grabs are missing). Also, there’s the well-known Mac OS X styling problem. We still haven’t found a perfect solution for this, so for now, if you use Mac style for Graphics View, embedded widgets will look a bit chunky when transformed. And finally, because this is all brand new API, we expect some bugs to appear in this pre-alpha phase, and hope to iron them out based on your feedback. But hey – Widgets on Graphics View! How about it??? ;-)

PS: The members of the WOC project are all present and listening on qt4-preview-feedback@trolltech.com (also available through nntp.trolltech.com). Now is the time that you can help hone Widgets on Canvas to be just as great as we all want it to be. So enjoy! We’re eagerly awaiting your feedback.

QShare(this)

Possibly related posts:

  1. Alien widgets on Mac
  2. State of HTML5 <canvas> in QtWebKit
  3. Lighthouse is integrated!

16 comments

1 Ankur November 22, 2007 at 12:36 pm
 

Can’t wait to get my QWidgets on QGraphicsView at workplace and dazzle everyone.

2 opsi November 22, 2007 at 1:58 pm
 

Looks amazing!, you just got me to update from 4.3 to svn head just for this ;P

3 xrg November 22, 2007 at 3:27 pm
 

Looking forward to integrate the feature to kshower…

4 Peter November 22, 2007 at 3:38 pm
 

Great, have been waiting for this. I will get this snapshot asap.

5 Gopala Krishna November 22, 2007 at 3:45 pm
 

Great work! If only plasma had waited for qt4.4 , there wouldn’t be duplication of some work :-)
Anyways very cool feature, hats off to you all responsible for this feature :)

6 Enrico Ros November 22, 2007 at 3:47 pm
 

Expect a lot of traffic on your ftp tonight ;-) !! (I will be polling every msec ;-) )

7 Andy Brice November 22, 2007 at 6:57 pm
 

Could lead to some interesting possibilities. Is it possible to place a drop-shadow behind a widget in QGraphicsView? The obvious way to do this would be to make the drop-shadow a child of the widget. But the children of a widgets are always stacked above the widget in the z order.

8 niko November 22, 2007 at 7:56 pm
 

wow – this is really amazing!!

9 wysota November 22, 2007 at 9:25 pm
 

Ok, so how did you solve the focus problem? Who gets the focus if one scene is displayed in more than one view? Could you explain what the problem was and what the final behaviour is? And maybe some hints on how did you actually solve it…

10 Andreas November 22, 2007 at 9:43 pm
 

Andy Brice: There’s a separate API for rendering window decorations – you can render drop-shadows there too. Check out QGraphicsWidget::paintWindowFrame() and friends. We haven’t added classes for window decos, but you can do that yourself easily.

Wysota: The focus problem – when a view gains focus, it gives the scene focus. If another view gains focus, the first loses focus, stealing focus from the scene, and the other gives focus back to the scene. As for activation, if two views in the same window view the same scene, the scene is activated once. We went for the reference counting approach, ensuring that the scene is activated once and only once even though two active views are viewing it, and zero-or-one of the views has focus. When both views have been deactivated, the scene is deactivated. This also ensures that the scene stays active if two views in separate windows are viewing the same scene. The only drawback is that the inactive window will also render the scene as active. Enjoy!

11 wysota November 22, 2007 at 10:03 pm
 

> The only drawback is that the inactive window will also render the scene as active.

This indeed doesn’t seem very natural.

Great work! Keep it up you Trolls!

/me bows before the great trollish wisdom ;)

12 momesana November 23, 2007 at 3:24 am
 

Excellent!

13 Ronny Brendel November 23, 2007 at 4:48 pm
 

The Plasma-Developers are happy now I guess :D .

Awesome. Thanks

14 infoatdfx November 26, 2007 at 3:44 pm
 

Finally the waiting is over :-) . Is it also going to be integrated into Qt Jambi?

15 Marc November 28, 2007 at 9:07 am
 

Does this also work with embedded GLWidgets?

16 MarkoSan December 5, 2007 at 8:48 pm
 

Is this new 4.4 compatible with Qtopia?

Comments on this entry are closed.

Previous post:

Next post: