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. Is it possible to override designer double click functionality on a custom widget?
QtWS25 Last Chance

Is it possible to override designer double click functionality on a custom widget?

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 2 Posters 819 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.
  • K Offline
    K Offline
    KidTrent
    wrote on last edited by
    #1

    I've created a custom designer widget that inherits from QTableWidget. I'd like to override the double click functionality (that happens while you are in designer and that causes a pop up form that populates the table to appear) so that I can allow the user to select the columns AND column types (QLineEdit, QComboBox, QSpinBox, QCheckBox) to be used in the table.

    Currently, I assign this programmatically, but it would be much more convenient to do it via the designer. I can't seem to find anything revolving around the words "qt override designer double click functionality", at least nothing that actually pertains to the subject.

    Can anyone explain how or provide me to a link of said documentation?

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      That's not possible.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • K Offline
        K Offline
        KidTrent
        wrote on last edited by
        #3

        Darn, I figured since widgets like QLineEdit, QTableWidget, QLabel, and QComboBox all have different double click functionalities within the designer that we would be able to override that within our custom widgets as well...

        Are we able to open a custom form when we set a Q_PROPERTY value for a custom widget in the designer that returns the value to set the property to?

        My objective here is to be able to select each column name and type (and type attributes such as min/max for SpinBox, ComboBox items, etc) for the table in the designer. Without one or the other I don't see any non-hardcoded way of achieving this.

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          No, only the Qt-designer default editors are possible.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          1
          • K Offline
            K Offline
            KidTrent
            wrote on last edited by
            #5

            Darn, okay. Is there a list of these default editors anywhere so I can see what my options are?

            Christian EhrlicherC 1 Reply Last reply
            0
            • K KidTrent

              Darn, okay. Is there a list of these default editors anywhere so I can see what my options are?

              Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @KidTrent No, it's not - it's just the ones you've in the property editor, nothing more. It's just a simple tool to create uis, not a programming tool.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              0
              • K Offline
                K Offline
                KidTrent
                wrote on last edited by KidTrent
                #7

                I've been playing around with the Q_PROPERTY macro in my custom widget just because this has to be possible in some way, and I found out very early that it is....

                The solution is quite simple, you can make a popup window appear in the designer through the Q_PROPERTY macro. The hard part, for me, was making the window allow the user to configure properties from objects derived of Q_OBJECT (done).

                What I did was, create a Q_PROPERTY that calls a function on WRITE that opens the custom window. The READ call simply outputs if there settings are set or not, in my case "Options Set" and "Options Not Set".

                Q_PROPERTY(QString options READ getOptions WRITE setOptions);
                

                There are a two quirks I'm currently working through right now with this solution:

                • You have to actually change the options string value, instead of just clicking the input, for the setOptions function to be called.
                • The same window appears to popup even if you are running the program and not in design mode...
                • The values used in the designer, don't persist into runtime... working on this now. I thought about this for some time, the .u file could maybe be modified to store the values in xml i need to look more into this... Either this or save/load to/from settings.
                1 Reply Last reply
                0
                • Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @KidTrent said in Is it possible to override designer double click functionality on a custom widget?:

                  The same window appears to popup even if you are running the program and not in design mode...

                  Because properties are for run-time. The designer just use them to display you a simple ui to insert values for initialization phase (within setupUi) - nothing more.

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  K 1 Reply Last reply
                  0
                  • Christian EhrlicherC Christian Ehrlicher

                    @KidTrent said in Is it possible to override designer double click functionality on a custom widget?:

                    The same window appears to popup even if you are running the program and not in design mode...

                    Because properties are for run-time. The designer just use them to display you a simple ui to insert values for initialization phase (within setupUi) - nothing more.

                    K Offline
                    K Offline
                    KidTrent
                    wrote on last edited by
                    #9

                    I'm slowly starting to get a better understanding of how to accomplish what I need. I managed to correctly open the editor and override the actual "double click" functionality I was originally asking about. It is simple, but my mistake was thinking the double click functionality was just a double click... it actually runs the default item list in the task menu that appears when you right click the widget in the designer.

                    Anyways, anyone looking to "override" the designers "double click" functionality on custom widgets you need to add a custom QDesignerTaskMenuExtension to your custom widget. Then you can have the window that opens up set the tables columns and column properties of your widget.

                    Once I understood the idea, it took me like 5 minutes to implement (it looks scarier than it is). Qt has a pretty good example of this located here: https://doc.qt.io/qt-5/qtdesigner-taskmenuextension-example.html

                    Now I just have to figure out how to apply the results of my popup to the .ui file....

                    1 Reply Last reply
                    0

                    • Login

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