发布网友 发布时间:2022-04-23 06:38
共1个回答
热心网友 时间:2023-06-27 18:32
按照我的理解,假设有一个编辑控件,一个button,你点击button后,会在编辑控件中显示字符,如果是的话,那就如下
先假设你点击button会输出12345
class ourbutton : public QPushButton
{
Q_OBJECT
public:
ourbutton(QWidget *parent = 0) : QPushButton(parent)
{
connect(this, SIGNAL(clicked()),
this, SLOT(getText()));
}
signals:
void sendText(const QString &text);
private slots:
void getText() { emit sendText(tr("12345")) }
};
QLineEdit *edit = new QLineEdit();
ourbutton *button = new ourbutton();
connect(button, SIGNAL(sendText(const QString &text)),
);