C++ (Qt)signals: void signalNet(); public slots: void slotNet();
C++ (Qt)public slots: void slotWidget(); signals: void signalWidget();
C++ (Qt)void Widget::on_pushButton_clicked(){ connect(net,SIGNAL(signalNet()),this,SLOT(slotWidget()));}
C++ (Qt)#ifndef NET_H#define NET_H #include<QString> class net{ signals: void signalNet(QString); public slots: void slotNet(); public: net(); void test(); private: }; #endif // NET_H
C++ (Qt)#ifndef WIDGET_H#define WIDGET_H #include <QWidget>#include <QString> namespace Ui { class Widget;} class Widget : public QWidget{ Q_OBJECT public: explicit Widget(QWidget *parent = 0); ~Widget(); public slots: void slotWidget(QString); signals: void signalWidget(); private slots: void on_pushButton_clicked(); private: Ui::Widget *ui;}; #endif // WIDGET_H
C++ (Qt)#include "net.h" net::net(){}void net::slotNet(){ emit signalNet("signal");}
C++ (Qt)#include "widget.h"#include "ui_widget.h"#include "net.h" Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget){ ui->setupUi(this);} Widget::~Widget(){ delete ui;} void Widget::on_pushButton_clicked(){ connect(this, SIGNAL(signalWidget()),net,SLOT(slotNet())); connect(net,SIGNAL(signalNet(QString)),this,SLOT(slotWidget(QString)));} void Widget::slotWidget(QString str){ ui->label->setText(str);}
C++ (Qt)class net : public QObject{ Q_OBJECT ...
C++ (Qt)net *netStatus=new net;