Back to Blog home

Noises from the crypt… (Widgets on Graphics View update)

Published on Tuesday October 30, 2007 by Andreas Aardal Hanssen in Labs Qt Graphics View KDE | Comments

Feature freeze for 4.4 is closing in. The offices in the dev department are awfully quiet. A bit... too quiet. The snippety-snapping sound of brilliant minds tapping in code, merging changes, polishing APIs, writing tests, reviewing patches. An incredible atmosphere, you would have to just be there to sense it. This is the period of Qt development when most of the building blocks are assembled, and awesome features and improvements emerge like glowing fresh steel from the furnace. This is the most busy, the most stressful, and by far the most fascinating phase.

Today in particular, I almost felt emotional. Together with Jan-Arve, Jo, Bjørn Erik, Benjamin, Girish, all brilliant developers, and everyone else who has participated in the Widgets on Graphics View project, I had the sensation that things were fitting so well together that you'd almost think we hadn't invented these APIs, but rather uncovered ancient APIs from a past civilization. ;-) The pieces of the Widgets on Graphics View project are coming together. In very few weeks, they will be in your hands to test.

Early on, I was worried about many things. Prior to 4.2, I was almost convinced that adding embedded widget support to Graphics View would be an insane operation. Undoable. I think I was right. I'll just list some of the problems we foresaw then, here:

  • QWidget cannot render itself onto an arbitrary painter like QGraphicsItem can... :-((
  • QPen is cosmetic by default. Will all styled widgets look strange when transformed?
  • Will the styles' implicit pixmap caching slow everything down to the state of it being useless?
  • How does scroll optimization (QWidget::scroll) work for a transformed widget?
  • Qt already has widgets, do we have to clone all the APIs into separate Graphics Widgets with a duplicated implementation?
  • How can graphics items be part of the tab focus chain when they aren't based on QWidget? (QWidget::setTabOrder...)
  • Do we need support for window flags? How about window activation? When is a Graphics Window activated?
  • Is there a concept of top-level window decorations in Graphics View, similar to QMdiSubArea?
  • How can we fool a QWidget into embedding itself into QGraphicsScene without it interfering with other widgets as if it wasn't embedded? (Think about QuitOnLastWindowClosed, and so on...)

Sigh. Looking back, I don't quite understand how we've made it. After numerous discussions with the guys directly involved in the project, and Lars, Brad (thanks for those long discussions in the car!), Paul, Jasmin, and many many other trolls, we've found solutions to almost every single problem that we foresaw. And we even uncovered more problems. And solved those too. And what we got, what we have, and what we're honing, stabilizing, testing and reviewing these days, makes me emotional.

#include "mainwindow.h"
#include <QtGui>

int main(int argc, char **argv)
{
QApplication app(argc, argv);

QGraphicsScene scene;
scene.addWidget(new MainWindow); // embed the whole thing

QGraphicsView view(&scene);
view.show();

return app.exec();
}

I can't wait to merge our stuff into Qt/main. When we do, it'll be in the Qt/main snapshots. And then, you can all have a go. Give it a try. Embed your entire QMainWindow based app, with a QMdiArea central widget that embeds a QGraphicsView inside a QMdiSubWindow, and see it fly. When you do, you'll get emotional too. I swear.

Subscribe to Our Blog

Stay up to date with the latest marketing, sales and service tips and news.

The blog comment system has been migrated to a new platform. If you face any issues, please let us know via feedback@qt.io.