I apologize for the confusion. It seems that there is no constructor in QWidgetAction
that accepts a string as a parameter. Instead, you can set the text for the action using setText()
method after creating the object. Here’s an updated version of your code:
QWidgetAction* m_showClientsWindow = new QWidgetAction(this);
m_showClientsWindow->setText("Clients");
connect(m_showClientsWindow, &QAction::triggered, this, &MainWindow::s_menu_Clients);
QWidgetAction* m_showESP32sWindow = new QWidgetAction(this);
m_showESP32sWindow->setText("ESP32");
connect(m_showESP32sWindow, &QAction::triggered, this, &MainWindow::s_menu_ESP32s);
this->menuBar()->addAction(m_showClientsWindow);
this->menuBar()->addAction(m_showESP32sWindow);
In this updated code, I have removed the string parameter from the QWidgetAction
constructor and instead used the setText()
method to set the text for each action before connecting them to their respective slots.
内容由零声教学AI助手提供,问题来源于学员提问