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
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
QObject::connect(ui
->pushButton,
SIGNAL(clicked
()),
this,
SLOT(browse
()));
}
void MainWindow::browse()
{
tr
("Find Files"),
QDir::currentPath());
}
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());
}
To copy to clipboard, switch view to plain text mode
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)
{
Q_OBJECT
public slots:
void browse();
public:
explicit MainWindow
(QWidget *parent
= 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
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;
};
To copy to clipboard, switch view to plain text mode
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 ??
Bookmarks