UsersWidget::UsersWidget(QWidget *parent) : QWidget(parent){ setupUi(this); connect(bRefreshUser, SIGNAL(clicked()), SIGNAL(SignalToGetUserList())); QTimer::singleShot(1, this, SLOT(slotToSendSignal())); emit SignalToGetUserList();}
class MyWidget : public QWidget { Q_OBJECT public: MyWidget(); signals: void buttonClicked(); private: QPushButton *myButton; }; MyWidget::MyWidget() { myButton = new QPushButton(this); connect(myButton, SIGNAL(clicked()), this, SIGNAL(buttonClicked())); }
void UsersWidget::slotToSendSignal(){ emit SignalToGetUserList();}
UsersWidget::UsersWidget(QWidget *parent) : QWidget(parent){ emit SignalToGetUserList();}
UsersWidget::UsersWidget(QWidget *parent) : QWidget(parent){ slotToSendSignal(); }
... workWithDatabase = new WorkWithDatabase("minienterprise.htm"); usersWidget = new UsersWidget(this); connect(usersWidget, SIGNAL(SignalToGetUserList()), workWithDatabase, SLOT(SlotUsersList())); ...
#ifndef __USERSWIDGET_H__#define __USERSWIDGET_H__#include <QtGui>#include "ui_usersWidget.h"class UsersWidget : public QWidget, public Ui::usersWidget{ Q_OBJECT public: UsersWidget(QWidget *parent=0); public slots: void slotToSendSignal(); signals: void SignalToGetUserList();};#endif // __USERSWIDGET_H__
#include "usersWidget.h" UsersWidget::UsersWidget(QWidget *parent) : QWidget(parent){ setupUi(this); connect(bRefreshUser, SIGNAL(clicked()), SIGNAL(SignalToGetUserList())); //QTimer::singleShot(1, this, SLOT(slotToSendSignal())); //slotToSendSignal(); emit SignalToGetUserList();}void UsersWidget::slotToSendSignal(){ emit SignalToGetUserList();}
class WorkWithDatabase : public QObject { Q_OBJECT...public slots: void SlotUsersList();...};
...void WorkWithDatabase::SlotUsersList(){ qDebug()<<"SIGNAL WAS SENDED";}...
usersWidget = new UsersWidget(this);connect(usersWidget, SIGNAL(SignalToGetUserList()), workWithDatabase, SLOT(SlotUsersList()));
QTimer::singleShot(1, this, SLOT(slotToSendSignal()));