Molinghu9
玄狐道士
2017-07-20 02:45

关于Qt信号槽使用的问题

  • qt
 #include "mainwindow.h"
#include "ui_mainwindow.h"


MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{

    ui->setupUi(this);


    ui->OK_Button->setText(tr("OK"));
    ui->lineEdit->setText("Naive");

   // QObject::
    connect(OK_Button,SIGNAL(clicked()),lineEdit,SLOT(btn_clicked()));
}
void MainWindow::btn_clicked()
{
    QString str="Hello Earth";
    ui->lineEdit->setText(str);

}

MainWindow::~MainWindow()
{
    delete ui;
}
 #ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

#include<QPushButton>
#include<QLineEdit>
#include<QString>
#include <QPushButton>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
    QPushButton *OK_Button;
    QLineEdit *lineEdit;


private slots:
    void btn_clicked();



};

#endif // MAINWINDOW_H

编译运行后编译器给出QObject::connect: No such signal MainWindow::clicked() inxxxxxxxx的提示,请问该如何解决

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答