You are not logged in.

bnilsson

Beginner

  • "bnilsson" is male
  • "bnilsson" started this thread

Posts: 37

Location: Sweden

  • Send private message

1

Saturday, November 24th 2007, 3:11pm

subclassing QGraphicScene and/or QGraphicsScene

Hi!

I need to make a subclass of QGraphicsScene and/or QGraphivsView, where I implement drawItems() to have more control of the actual drawing. The reason is that I often have too much to draw into the port, and this locks up the application so it does not repond to clicks until the drawing is finished, which may take 20-30 seconds.

Concidering my low level of competence in C++ programming and the complexity of the qgraphicsscene/graphicsview sourcefiles, I would need help with an empty barebones myQGraphycsScene.cpp(+.h) and/or QGraphicsView.cpp(+.h) that would compile into my project without errors.

I have made a lame attempt without success.

I made a subclass of QGraphicsView successfully to implement the mouse events required for rubberband for zooming in and out, but as soon as I tried to add the drawItems() method I got stuck due to the dependency of QGraphicsViewPrivate.

Could someone possibly help me with this?
MacOSX user

This post has been edited 1 times, last edit by "bnilsson" (Nov 24th 2007, 3:59pm)


2

Saturday, November 24th 2007, 6:14pm

To draw your items you should call drawItems() on a QGraphicsScene not in a QGraphicsView.

This post has been edited 1 times, last edit by "marco" (Nov 24th 2007, 6:16pm)


bnilsson

Beginner

  • "bnilsson" is male
  • "bnilsson" started this thread

Posts: 37

Location: Sweden

  • Send private message

3

Saturday, November 24th 2007, 11:11pm

Thanks, I've realized this.
Nevertheless, the basic problem persists also for myQGraphicsScene.

I have creator, destructor, and drawItems in myQgraphicsScene, and that is all.
Apparently, this is not enough, since I get:

Quoted

/Library/Frameworks/QtGui.framework/Versions/4/Headers/qgraphicsscene.h:237: error: 'QGraphicsScenePrivate* QGraphicsScene::d_func()' is private

and more of the same.

There is a macro "Q_D(QGraphicsScene);" in the original QGraphicsScene which is defined as

#define Q_D(Class) Class##Private * const d = d_func()

expands into

QGraphicsScenePrivate const d = d_func()

To put toghether a simplified version of all myself this makes me think I'm on thin ice.
I prefer to have a good reason and understanding for the stuff I put in the subclass files, and in this case I can't say I do.

Please direct me on a minimal and consistent way of introducing and using (my)QGraphicsScenePrivate class here.
MacOSX user

This post has been edited 2 times, last edit by "bnilsson" (Nov 25th 2007, 10:03am)