Qt World Summit: Submit your Presentation

Is there a better way to schedule?

  • I have a slot that when checkboxes are clicked sets the visibility of widgets on a form, I then get the geometry to adjust the geometry of the form, however I've found this will only work if I allow the widgets visibility to take effect which isn't instant after calling setVisible, I've now got a one shot timer triggering 20 milliseconds after calling the setVisible on the widgets and this works, but I feel its a bit hacky...is there a better way to achieve this?

  • Lifetime Qt Champion

    Well there is the showEvent which is often used for such cases.
    If you already subclassed the widgets its good but if thats not an option then
    an event filter can be used to know when they are ready.

  • @mrjj , thank you, is there an example I can look at?

  • add show event to your widget
    void showEvent(QShowEvent *) override;

    when show event arrives, do your stuff. This func will be called when the widget is set visible(true).

    Sure there is hide event as well for setVisible( false ).
    void hideEvent(QHideEvent *) override;

    This will be clean.

Log in to reply