Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-126721

[REG 6.6->6.7] Overriden setVisible() no longer gets called when parent widget is shown

XMLWordPrintable

    • fc4c6fb5f (dev), 705dbea2a (6.8), a007c5aa0 (6.7)

      The virtual function QWidget::setVisible(bool) has earlier always been called when the visibility status of a widget changed. So it has been used as a way to do lazy initialization in a custom widget: implement a setVisible() override and do the init there, just before the widget gets shown. However, after https://codereview.qt-project.org/c/qt/qtbase/+/536262 this no longer works. This has resulted in https://bugreports.qt.io/browse/QTBUG-126218, since QPrintPreviewWidget used that mechanism.

      Now the doc of setVisible() is pretty clear that overriding that function is not the way to go; instead it recommends showEvent() etc. So the choice in QPrintPreviewWidget was presumably not so smart. And presumably it not so hard to fix/workaround, although there may be some BIC complexities. Nonetheless there are some issues here:

      1. There are ~20 other overridden setVisible() functions in qtbase alone - are we sure this behavior change do not cause issues with any of those?
      2. Are we comfortable inducing this behavior change on users?

        For Gerrit Dashboard: QTBUG-126721
        # Subject Branch Project Status CR V

            vestbo Tor Arne Vestbø
            vgt Eirik Aavitsland
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes