lucie1985
19th July 2015, 21:42
hello people :) . i need some help.
I have a mainWindow(1rst Function of .cpp) with a menubar. the menubar help to choise a directory with SiGNAL & SLOT (2nd Function). The directory is for example : home\users\...... .
My problem : I want to pass the directory-value(here a QString) to another function!!! But it is not happened.
here is my code:
mainwindow.h
class MainWindow:public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
QString getDirName() const;
public slots:
void selectdirectory() ;
private:
QMenu *menuFile;
QAction *Dateipath;
};
#endif // MAINWINDOW_H
mainwindow.cpp
MainWindow::MainWindow(QWidget *parent):QMainWindow(parent)
{
menuFile = menuBar()->addMenu("&File");
Dateipath = new QAction("&Select directory", this);
menuFile -> addAction(Dateipath);
Dateipath->setShortcut(QKeySequence("ctrl+s"));
QObject::connect(Dateipath, SIGNAL(triggered()),this, SLOT(selectdirectory()));
}
void MainWindow::selectdirectory()
{
QString mydirectory= "home\users\........"
}
QString MainWindow::getDirName() const
{
I need QString mydirectory here
}
I have a mainWindow(1rst Function of .cpp) with a menubar. the menubar help to choise a directory with SiGNAL & SLOT (2nd Function). The directory is for example : home\users\...... .
My problem : I want to pass the directory-value(here a QString) to another function!!! But it is not happened.
here is my code:
mainwindow.h
class MainWindow:public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
QString getDirName() const;
public slots:
void selectdirectory() ;
private:
QMenu *menuFile;
QAction *Dateipath;
};
#endif // MAINWINDOW_H
mainwindow.cpp
MainWindow::MainWindow(QWidget *parent):QMainWindow(parent)
{
menuFile = menuBar()->addMenu("&File");
Dateipath = new QAction("&Select directory", this);
menuFile -> addAction(Dateipath);
Dateipath->setShortcut(QKeySequence("ctrl+s"));
QObject::connect(Dateipath, SIGNAL(triggered()),this, SLOT(selectdirectory()));
}
void MainWindow::selectdirectory()
{
QString mydirectory= "home\users\........"
}
QString MainWindow::getDirName() const
{
I need QString mydirectory here
}