标签:csdn details sign string ack connect memory tao 名称
参考链接1:http://blog.csdn.net/skyhawk452/article/details/6121407
参考链接2:http://blog.csdn.net/memory_exception/article/details/50953005
信号与槽可以通过使用手写代码显式的实现关联 ,也可以运用 QMetaObject 类规定的槽 函数命名范式来实现自动关联。
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()));
#include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QString a = "calculate"; setWindowTitle(tr("%1").arg(a)); //connect(ui->calButton,SIGNAL(clicked()),this,SLOT(on_calButton_clicked())); //QMetaObject::connectSlotsByName(this); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_calButton_clicked() { int a = (ui->firstLineEdit->text()).toInt() + (ui->secondLineEdit->text()).toInt(); ui->resultLineEdit->setText(tr("%1").arg(a)); }
标签:csdn details sign string ack connect memory tao 名称
原文地址:http://www.cnblogs.com/lxmwb/p/6220733.html