I have declared three slots in my mainwindow.h
and given their definitions in the implementation file. Here is the MainWindow class:
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
signals:
void nextImage(int direction);
private slots:
void updateImage(void);
void cameraControl(void);
void cameraStart(void);
private:
Ui::MainWindow *ui;
CMUCamera *camera;
ImageProcessing *process;
RenderImage *renderImage;
bool saveImgFlg;
QString path;
};
Going to mainwindow.ui, I have designed a menu bar for the user interface. There are three QActions, as shown in the figure below:
Then, I do the signal and slot editing. But the defined slots (udpateImage
, cameraStart
and cameraControl
) in the header file do not appear in the slot list, as shown in the figure below:
Are there any other steps I missed here or is there something I did wrong? It is also noted QMainWindow
, in the framework of which these slots should show up, I guess, is also not displayed in the list.
To connect the signal to the slot, we use QObject::connect(). There are several ways to connect signal and slots. The first is to use function pointers: connect(sender, &QObject::destroyed, this, &MyObject::objectDestroyed);
No. Signals cannot be public or private. Qt signals are protected class methods.
I know why that happens. For adding those custom slots, in addition to defining them in header and implementation files, they also should be added in priori by right clicking the QMainWindow
, going to change signals and slots
and manually adding them in the slot panel. This way is simpler than to code signal&slots.
A similar question has been reported here: my slots don't appear in the signal slot editor
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With