Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Model/View and Dock Widgets: a menu conundrum
QtWS25 Last Chance

Model/View and Dock Widgets: a menu conundrum

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 384 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Phil K
    wrote on 1 Nov 2020, 17:47 last edited by
    #1

    I want to use dock widgets to manage model/view documents, one document per dock. I am looking for the best practice for placement of document-related menu items, i.e. "new/open/close/save/save as". In my QMainWindow File menu I can easily add the "new/open" menu items and create empty or populated dock widgets, as needed. The issue is the "close/save/save as" menu items. Am I forced to use context menus within the dock widget itself? By this I mean there is no analog to QMDIArea::subWindowActivated, a convenient hook on which to update the main menu when using MDI. Managing documents within dock widgets, requires a different approach. What is the best practice here? Context menus?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 1 Nov 2020, 18:47 last edited by
      #2

      Hi,

      No you are not. You can manage them with the "current active document" paradigm. The menu slots shall act on the currently active area/widget/etc.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • P Offline
        P Offline
        Phil K
        wrote on 1 Nov 2020, 19:15 last edited by
        #3

        @SGaist I recognize that I have to code something here -- on what dock event would I alter the current document? A dock widget raise event?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 1 Nov 2020, 19:28 last edited by
          #4

          What kind of document do you have ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • P Offline
            P Offline
            Phil K
            wrote on 1 Nov 2020, 19:36 last edited by Phil K 11 Jan 2020, 19:37
            #5

            I will probably save the model data to a json format, but that is tangential to the UI question. If, for example, I have 5 dock widgets open, 2 are tabbed, 2 are floating and 1 is invisible, what is the "current document" in that context? I guess I could reimplement QDockWidget's changeEvent and look for an activation change event or something similar.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 1 Nov 2020, 20:05 last edited by
              #6

              So you have one active dock at a time. Rather than focusing on the dock itself, it should rather be its widget that notifies that is has been modified as well as become the target of your menus/actions.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • P Offline
                P Offline
                Phil K
                wrote on 1 Nov 2020, 23:26 last edited by
                #7

                OK, so I just connected QApplication::focusChange to a slot in the main window where I ask the question "is the widget that now has focus a view of the type I am interested in?" If yes, I change the related menus accordingly. The "Ah Ha!" moment for me indeed was to think about the views, not the docks. I first tried installing an event filter on the views to look for FocusIn events, which works, but even that is unnecessary given the focusChange api available from the QApplication.

                1 Reply Last reply
                0

                6/7

                1 Nov 2020, 20:05

                • Login

                • Login or register to search.
                6 out of 7
                • First post
                  6/7
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved