I have created several menu items in Qt but I do not know how to connect them to to the qtdialog which I created
for the menu items :
mainwindow.h
........
void get_started_info();
private:
Ui::MainWindow *ui;
//! Create the menu classes
void createActions();
void createMenus();
//! Menu Items
};
#endif // MAINWINDOW_H
........
void get_started_info();
private:
Ui::MainWindow *ui;
//! Create the menu classes
void createActions();
void createMenus();
//! Menu Items
QMenu *home;
QMenu *help;
QAction *quit;
QAction *start;
};
#endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode
mainwindow.cpp
void MainWindow::createActions()
{
QPixmap startpix
("../src/img/start.png");
start
= new QAction(startpix,
"&Get Started",
this);
start->setStatusTip(tr("Learn how to use this program"));
connect(start,SIGNAL(triggered()),qApp,SLOT(get_started_info()));
}
void MainWindow::createMenus()
{
home = menuBar()->addMenu(tr("&Home")); //! Adding a home item
help = menuBar()->addMenu(tr("H&elp")); //! Adding a help item
help->addAction(start); //! Adding About under the help
}
void MainWindow::createActions()
{
QPixmap startpix("../src/img/start.png");
start = new QAction(startpix,"&Get Started",this);
start->setStatusTip(tr("Learn how to use this program"));
connect(start,SIGNAL(triggered()),qApp,SLOT(get_started_info()));
}
void MainWindow::createMenus()
{
home = menuBar()->addMenu(tr("&Home")); //! Adding a home item
help = menuBar()->addMenu(tr("H&elp")); //! Adding a help item
help->addAction(start); //! Adding About under the help
}
To copy to clipboard, switch view to plain text mode
in the mainwindow.cpp I also have this class which should show the dialog
void MainWindow::get_started_info()
{
get_started one(this); //create a object directly
one.exec(); //modal dialog
}
void MainWindow::get_started_info()
{
get_started one(this); //create a object directly
one.exec(); //modal dialog
}
To copy to clipboard, switch view to plain text mode
I also have get_started.h / get_started.cpp / get_strated.ui
I think there is an issue with this lines :
start
= new QAction(startpix,
"&Get Started",
this);
start->setStatusTip(tr("Learn how to use this program"));
connect(start,SIGNAL(triggered()),qApp,SLOT(get_started_info()));
start = new QAction(startpix,"&Get Started",this);
start->setStatusTip(tr("Learn how to use this program"));
connect(start,SIGNAL(triggered()),qApp,SLOT(get_started_info()));
To copy to clipboard, switch view to plain text mode
is it possible to show the dialog when the "Get Started" is clicked from the menu ?
thank you
Bookmarks