Confuse of Signal and Slot
Solved
General and Desktop
-
I wrote a simple function like this :
#include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); connect(ui->BrowseBtn,&QPushButton::clicked,this, &MainWindow::Browse); QDir mDir("D:/Document"); qDebug() << mDir.entryList(); } MainWindow::~MainWindow() { delete ui; } void MainWindow::Browse(){ ui->FileShow->setText("GG!"); qDebug() << "GG"; }
and it works,
However I change connect toconnect(ui->BrowseBtn,SIGNAL(QPushButton::clicked()),this, SLOT(MainWindow::Browse()));
it won't work!!! Can anyone tell me why??
What's the different?? -
Perhaps if you write it like this?
connect(ui->BrowseBtn, SIGNAL(clicked()), this, SLOT(Browse()));
-
as @Jan-Willem writes you are not using the correct syntax
for the OLD syntax, you do not append the class type inside the SLOT() and SIGNAL()