PDA

View Full Version : Display multiple QGraphicsView in same screen while all fullscreen



squeegedog
6th February 2014, 14:11
I've been trying different approaches to solve my problem for quite some time, but nothing seems to work.

Making a game for one of my CPE classes and I've gotten my game background to load, with scrolling and zooming all working properly. However, in order to overlay buttons that allow the different game functions, they cannot be built into that QGraphicsScene as they will then move and zoom with the display. Thus I'm trying to create another QGraphicsView in transparent mode with its own QGraphicsScene containing just the game overlay information that stays static despite the state of the background.

I've tried using the Forms editor, but it wont let me stretch a GraphicsView to it while having buttons overlay.

I've tried just setting up two separate QGraphicsView items in my code not using a UI edited form and disabling my MainWindow, but they both then populate in their own windows as fullscreen. Setting one as the child of the other results in the parent being fullscreen and the child being partial.

I've tried making both GraphicsView's children of the MainWindow, but once again they end up only filling part of the screen.

I've probably tried a few other approaches that I can't think of after hours of manipulating things in different manners, but nothing generates my expected result, thus leading me hear to ask.

Any advice/insight would be a major help.
Thanks in advance!

anda_skoa
6th February 2014, 14:37
they cannot be built into that QGraphicsScene as they will then move and zoom with the display.

Even when you set ItemIgnoresTransformations?


Setting one as the child of the other results in the parent being fullscreen and the child being partial.

Did you set a layout on the parent?

Cheers,
_

squeegedog
6th February 2014, 15:54
Even when you set ItemIgnoresTransformations

Setting that works well with the zoom, however, the labels still move with the screen scroll.


Did you set a layout on the parent

No, the second view is being forced to the upper-left corner of the display. I'm getting decent with working in QT, but I haven't figured out setting layouts etc from code, only using the forms editor.

anda_skoa
6th February 2014, 17:30
Layouts in code basically work like this



QVBoxLayout *layout = new QVBoxLayout(parentWidget);
layout->addWidget(childWidget);


Cheers,
_

squeegedog
6th February 2014, 22:44
Thanks!

At first I was looking at your solution all wrong, but by adding the layout to my main QGraphicsView, I can add buttons to it that are unaffected by Scene changes. Also removing the need for multiple displays

d_stranz
7th February 2014, 00:08
adding the layout to my main QGraphicsView, I can add buttons to it that are unaffected by Scene changes

Nice. That's something I can probably use, if I can remember this thread when the time comes to use it...