Skip to content

Commit

Permalink
PaletteWidget: Do not use autoconnection mechanism for slots used in
Browse files Browse the repository at this point in the history
QMenu

Currently whenever UI gets loaded and we try to connect a slot with a
signal emitted in QAction, for example in appending frame, inserting it,
etc. we get warnings like these:

qt.core.qmetaobject.connectslotsbyname: QMetaObject::connectSlotsByName: No matching signal for on_actionAdd_Frame_triggered()

This is because MOC tries to automatically connect functions which have
"on_objectname_triggered" signature, and it can't find a matching signal
for it by default. So the solution for that is to simply not use the
autoconnection mechanism by changing names of those slots, removing
"on" prefix from them.
  • Loading branch information
tetektoza committed Nov 15, 2023
1 parent 46d4390 commit 30337b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions source/palettewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,12 +505,12 @@ void PaletteWidget::ShowContextMenu(const QPoint &pos)
contextMenu.setToolTipsVisible(true);

QAction action0("Undo", this);
QObject::connect(&action0, SIGNAL(triggered()), this, SLOT(on_actionUndo_triggered()));
QObject::connect(&action0, SIGNAL(triggered()), this, SLOT(actionUndo_triggered()));
action0.setEnabled(this->undoStack->canUndo());
contextMenu.addAction(&action0);

QAction action1("Redo", this);
QObject::connect(&action1, SIGNAL(triggered()), this, SLOT(on_actionRedo_triggered()));
QObject::connect(&action1, SIGNAL(triggered()), this, SLOT(actionRedo_triggered()));
action1.setEnabled(this->undoStack->canRedo());
contextMenu.addAction(&action1);

Expand Down Expand Up @@ -801,12 +801,12 @@ void PaletteWidget::on_closePushButtonClicked()
((MainWindow *)this->window())->paletteWidget_callback(this, PWIDGET_CALLBACK_TYPE::PWIDGET_CALLBACK_CLOSE);
}

void PaletteWidget::on_actionUndo_triggered()
void PaletteWidget::actionUndo_triggered()
{
this->undoStack->undo();
}

void PaletteWidget::on_actionRedo_triggered()
void PaletteWidget::actionRedo_triggered()
{
this->undoStack->redo();
}
Expand Down
4 changes: 2 additions & 2 deletions source/palettewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ private slots:
void on_saveAsPushButtonClicked();
void on_closePushButtonClicked();

void on_actionUndo_triggered();
void on_actionRedo_triggered();
void actionUndo_triggered();
void actionRedo_triggered();

void on_pathComboBox_activated(int index);
void on_displayComboBox_activated(int index);
Expand Down

0 comments on commit 30337b2

Please sign in to comment.