Skip to content

Commit c571aba

Browse files
committed
BUG: Fix ctkMenuButton for Qt6
Menu always appeared, even when clicking outside the menu region of the button. Fixed by blocking signals instead of disconnecting an internal slot.
1 parent 027f20e commit c571aba

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Libs/Widgets/ctkMenuButton.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,17 @@ void ctkMenuButton::mousePressEvent(QMouseEvent *e)
186186
{
187187
Q_D(ctkMenuButton);
188188
// we don't want to open the menu if the mouse is clicked anywhere on
189-
// the button, only if it's clicked on the indecator
189+
// the button, only if it's clicked on the indicator
190+
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
190191
this->disconnect(this,SIGNAL(pressed()), this, SLOT(_q_popupPressed()));
191192
this->QPushButton::mousePressEvent(e);
193+
#else
194+
// Use blockSignals to prevent internal Qt slots from being called
195+
// (disconnecting internal implementation slots does not work in Qt6)
196+
const bool wasBlocked = this->blockSignals(true);
197+
this->QPushButton::mousePressEvent(e);
198+
this->blockSignals(wasBlocked);
199+
#endif
192200
if (e->isAccepted())
193201
{
194202
return;

0 commit comments

Comments
 (0)