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. Overwrite single function of an class
Qt 6.11 is out! See what's new in the release blog

Overwrite single function of an class

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.7k Views 1 Watching
  • 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.
  • QT-static-prgmQ Offline
    QT-static-prgmQ Offline
    QT-static-prgm
    wrote on last edited by
    #1

    Hi,

    i have Combobox and when you klick it i need to call a custom function to update the list entries BEFORE the list is shown. I thought there may be a signal such as klicked or pressed but haven't found something like that in the docs.
    As an alternative i thought of overwrite the MousePressEvent function, let my own thing happen first and execute the original next. But therefore i need to make my own class inherited from QComboBox and make my own event function. That's a lot of stuf for such a simple problem. So hopefully there is an easier way. Any ideas??

    1 Reply Last reply
    0
    • QT-static-prgmQ Offline
      QT-static-prgmQ Offline
      QT-static-prgm
      wrote on last edited by
      #6

      settings window knows NOTHING about oglviewerwidget. But the viewerwidget about the settings.

      I found a way to solve. The settingsmanager is a singelton, so i can connect the manager who holts the values to the mainwindow

      1 Reply Last reply
      0
      • m.sueM Offline
        m.sueM Offline
        m.sue
        wrote on last edited by
        #2

        Hi,

        you can overwrite the virtual function showPopup()

        -Michael.

        1 Reply Last reply
        1
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #3

          Hi,

          The idea sounds dangerous, why update it each time you are going to show the popup ?

          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
          • QT-static-prgmQ Offline
            QT-static-prgmQ Offline
            QT-static-prgm
            wrote on last edited by
            #4

            Thank you m.sue. I think that is the best function to overwrite.

            @SGaist That's why i always love your answers, you go deeper in and find the real problem. Yeah the overwrite to update always is just a workaround.

            So i have my MainWindow that has an Combobox. And there is a OGLViewerWidget and a settingsWindow. The Settingswindow i only known to the oglviewerwidget. When i change the entries for the combox in the settings i see no way to tell MainWindow something changed.

            But all settings are saved in the SettingsManager which is an singleton, so i can simply get the pointer to the Manager and get all entries for the Combobox in the Mainwindow. But the problem is, when to update. Easiest way (for me) is to do it everytime you use that Combobox.

            But maybe you have a different idea.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #5

              Why does SettingsWindow know anything about your OGLViewerWidget ?

              What you can do is add properties to your SettingsWindow and connect them to your various widgets the way you need them.

              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
              • QT-static-prgmQ Offline
                QT-static-prgmQ Offline
                QT-static-prgm
                wrote on last edited by
                #6

                settings window knows NOTHING about oglviewerwidget. But the viewerwidget about the settings.

                I found a way to solve. The settingsmanager is a singelton, so i can connect the manager who holts the values to the mainwindow

                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