dexli
1st May 2011, 20:08
Hi all,
it seems to be simple but it isn't.
Using the Designer I got the usual MainWindow class with
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QObject::connect(ui->pushButton,SIGNAL(clicked()), this,SLOT(browse()));
}
void MainWindow::browse()
{
QString directory = QFileDialog::getExistingDirectory(this,
tr("Find Files"), QDir::currentPath());
}
As one can see I try to connect the clicked signal of a QPushButton to a slot of MainWindow ( which is by the way not visible in the Desinger)
class MainWindow : public QMainWindow
{
Q_OBJECT
public slots:
void browse();
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
QComboBox *fileComboBox;
QComboBox *directoryComboBox;
};
The code complies without an error and the application starts but the browse Method is never called if the button is clicked.
What is going wrong here.
Have fun
dexli
Added after 5 minutes:
Don' know what happen but after recompiled it the x time it works.
How do i delete this thread ??
it seems to be simple but it isn't.
Using the Designer I got the usual MainWindow class with
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QObject::connect(ui->pushButton,SIGNAL(clicked()), this,SLOT(browse()));
}
void MainWindow::browse()
{
QString directory = QFileDialog::getExistingDirectory(this,
tr("Find Files"), QDir::currentPath());
}
As one can see I try to connect the clicked signal of a QPushButton to a slot of MainWindow ( which is by the way not visible in the Desinger)
class MainWindow : public QMainWindow
{
Q_OBJECT
public slots:
void browse();
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
QComboBox *fileComboBox;
QComboBox *directoryComboBox;
};
The code complies without an error and the application starts but the browse Method is never called if the button is clicked.
What is going wrong here.
Have fun
dexli
Added after 5 minutes:
Don' know what happen but after recompiled it the x time it works.
How do i delete this thread ??