PDA

View Full Version : Graphics/View + dialogs



AeroB
18th June 2012, 16:05
Hello

Project description:
I am new to the forum and to Qt development in general. I am developing an application that reads geographical data from a file and displays them on screen, as a zoomable/movable map. The items on the map are a subclass of QGraphicsItem and I am using a cusom QGraphicsView to display them and facilitate zooming and panning, so the basic functions are all working.

The problem
I am now trying to add dialogs. For example, a custom settings dialog that would allow the user to turn various map objects on/off. These setting wondows should be in the foreground and fixed on the screen, meaning that even if the user pans or zooms the underlying map, the dialog remains fixed (e.g. in the centre of the screen or anywhere the user drags them).

What I tried..
I have tried reimplementing the paintEvent and/or drawForeground functions of my QGraphicsView. I have only got as far as drawing a simple square. I managed to get it to the right place using mapToScene and it stayed fixed when zooming but translated when panning the view, so it did not work. I am also unsure how events such as clicks etc. on the dialog would be handled this way.

My question
Could someone please suggest a more sophisticated method to handle this type of task? To summarize, the main requirements are: the dialog stays fixed relative to the view, events can be handled. The dialogs would contain custom drawn buttons, check boxes.

Thank you!

wysota
18th June 2012, 16:56
The first question is whether your dialogs should be part of the view as well or not. Because the easiest way is to just use QDialog instances that will hover over the window containing your view.

AeroB
19th June 2012, 15:39
Thanks for your reply. Indeed it is easier to use custom QDialogs. Cheers!