Qt 小技巧 根据显示文本、信号槽创建QPushButton
时间:2011-01-07 来源:93度的饼干
/** descr:创建QPushButton的实例 input:text 按钮上显示的内容;receiver 按钮创建信号槽时的槽对象;member 接受信号的槽 output:void return:创建的QPushButton实例 */ QPushButton *Screenshot::createButton(const QString &text, QWidget *receiver, const char *member) { QPushButton *button = new QPushButton(text); button->connect(button, SIGNAL(clicked()), receiver, member); return button; }具体调用此方法的代码如下
QPushButton *quitScreenshotButton; quitScreenshotButton = createButton(tr("Quit"), this, SLOT(close()));
相关阅读 更多 +