Skip to content

Custom Instructions

In TeachPendantDemo, create three files:

In widget_mannager.cpp, bind the two signals signal_userdefine_cmd_init and signal_userdefine_cmd_alter to our interface:

cpp
WidgetManager::WidgetManager(QObject *parent) :
    QObject(parent)
{
    Nextp::getInstance();


    // Register my_custom_widget interface
    connect(Nextp::getInstance(),SIGNAL(signal_openWidget()),this,SLOT(slot_openMyCustomWidget()));


    // Register my_custom_command interface
    connect(Nextp::getInstance(),SIGNAL(signal_userdefine_cmd_init(int)),this,SLOT(slot_openMyCustomCommand(int)));
    connect(Nextp::getInstance(),SIGNAL(signal_userdefine_cmd_alter(int,QString,QString)),this,SLOT(slot_modifyMyCustomCommand(int,QString,QString)));


    // Register close interface signal. When this system signal is received, all custom interfaces need to be closed
    connect(Nextp::getInstance(),SIGNAL(signal_closeWidget()),this,SLOT(slot_closeAllCustomWidget()));


    // Register callback for receiving controller messages
    connect(Nextp::getInstance(),SIGNAL(signal_receiveMessage(const quint16 &,const QByteArray &)),this,SLOT(slot_receiveMessage(const quint16 &,const QByteArray &)));
}

void WidgetManager::slot_openMyCustomCommand(int)
{
    Nextp::getInstance()->setWidgetParentLocation((QWidget*)MyCustomCommand::getInstance(),86,96);
    MyCustomCommand::getInstance()->show();
    MyCustomCommand::getInstance()->raise();
    Nextp::getInstance()->widgetShowFinish();
}

The first signal is bound to the open event, and the second signal is bound to the modify event.

When implementing slot_openMyCustomCommand, open a brand new custom_commamd.ui.

When implementing slot_modifyMyCustomCommand, open an interface and initialize it based on the three parameters int, QString, and QString.

  • my_custom_command.h
  • my_custom_command.cpp
  • my_custom_command.ui