Results 1 to 3 of 3

Thread: Graphics/View + dialogs

  1. #1
    Join Date
    Jun 2012
    Qt products

    Default Graphics/View + dialogs


    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!

  2. #2
    Join Date
    Jan 2006
    Warsaw, Poland
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits

    Default Re: Graphics/View + dialogs

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.

  3. #3
    Join Date
    Jun 2012
    Qt products

    Default Re: Graphics/View + dialogs

    Thanks for your reply. Indeed it is easier to use custom QDialogs. Cheers!

Similar Threads

  1. Graphics View : too many lines
    By natnan in forum Qt Programming
    Replies: 6
    Last Post: 28th January 2010, 11:15
  2. Add graphics view to tab widget?
    By Ishmael in forum Qt Programming
    Replies: 1
    Last Post: 26th September 2009, 05:31
  3. OpenGL with Graphics View?
    By Dutch112 in forum Qt Programming
    Replies: 15
    Last Post: 19th May 2009, 08:21
  4. graphics view painting
    By dognzhe in forum Qt Programming
    Replies: 3
    Last Post: 12th May 2009, 07:26
  5. graphics view slow
    By dognzhe in forum Qt Programming
    Replies: 16
    Last Post: 11th May 2009, 17:36


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.