Overwrite single function of an class



  • 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??



  • Hi,

    you can overwrite the virtual function showPopup()

    -Michael.


  • Lifetime Qt Champion

    Hi,

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



  • 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.


  • Lifetime Qt Champion

    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.



  • 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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.