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

REG: uic creates ambiguous signal/slot connections

    XMLWordPrintable

Details

    • All
    • 98a89fb711a15fcf9f541f7b4a8ae7492e5a445c (qt/qtbase/dev) e0fecdc7bc7b3dbd6a6f9046d43450b3bdd38a60 (qt/qtbase/6.0)

    Description

      Since Qt 6, uic has started producing invalid connection statements when the signal or slot has overloads.

      To reproduce (how the attached example was produced):
      1. Create a "Qt Widgets" application using the template in Qt Creator
      2. Go to the form editor and add a vertical slider to the form
      3. Enter signal/slot editing mode and create a connection from slider to widget parent
      4. Make sure "inherited from QWidget" is checked, then pick "valueChanged(int)" on the slider and "repaint()" on the widget.
      5. Try to compile.

      With Qt 5.15 it produces the following code:

      QObject::connect(verticalSlider, SIGNAL(valueChanged(int)), Widget, SLOT(repaint()));
      

      Which works fine.

      But with Qt 6 uic produces the following code:

      QObject::connect(verticalSlider, &QSlider::valueChanged, Widget, &QWidget::repaint);
      

      This fails to compile, because QWidget::repaint is ambiguous:

      C:\dev\diverse\bugs\build-uicSignals-Qt_dev-Debug\ui_widget.h(41): error C2665: 'QObject::connect': none of the 3 overloads could convert all the argument types
      C:\dev\qt5-dev\base\include\QtCore\../../src/corelib/kernel/qobject.h(441): note: could be 'QMetaObject::Connection QObject::connect(const QObject *,const char *,const char *,Qt::ConnectionType) const'
      C:\dev\qt5-dev\base\include\QtCore\../../src/corelib/kernel/qobject.h(198): note: or       'QMetaObject::Connection QObject::connect(const QObject *,const QMetaMethod &,const QObject *,const QMetaMethod &,Qt::ConnectionType)'
      C:\dev\qt5-dev\base\include\QtCore\../../src/corelib/kernel/qobject.h(195): note: or       'QMetaObject::Connection QObject::connect(const QObject *,const char *,const QObject *,const char *,Qt::ConnectionType)'
      C:\dev\diverse\bugs\build-uicSignals-Qt_dev-Debug\ui_widget.h(41): note: while trying to match the argument list '(QSlider *, void (__cdecl QAbstractSlider::* )(int), QWidget *, overloaded-function)'
      

      In this case, I think qOverload() is needed to disambiguate the slot.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              jkobus Jarek Kobus
              esabraha Eskil Abrahamsen Blomfeldt
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes