menu.cpp
#include "menu.h"
Menu::Menu(Cards *window, QWidget *parent) :
QWidget(parent)
{
window->setWindowTitle(tr("Cards - main menu"));
QPushButton *createButton = new QPushButton(tr("&Create"));
QPushButton *searchButton = new QPushButton(tr("&Search"));
QPushButton *loginButton = new QPushButton(tr("&Login"));
QPushButton *registerButton = new QPushButton(tr("&Register"));
QGridLayout *layout = new QGridLayout;
layout->addWidget(createButton, 2, 0);
layout->addWidget(searchButton, 3, 0);
layout->addWidget(loginButton, 4, 0);
layout->addWidget(registerButton, 5, 0);
setLayout(layout);
connect(createButton, SIGNAL(clicked()), this, SLOT(startCreate(window))); // !
connect(searchButton, SIGNAL(clicked()), this, SLOT(startSearch(window))); // ! БЯ
connect(loginButton, SIGNAL(clicked()), this, SLOT(startLogin(window))); // ! ДА
connect(registerButton, SIGNAL(clicked()), this, SLOT(startRegister(window))); // !
}
void Menu::startCreate(Cards *window)
{
CreateMenu *cm = new CreateMenu(window);
window->setCentralWidget(cm);
}
void Menu::startSearch(Cards *window)
{
SearchMenu *sm = new SearchMenu(window);
window->setCentralWidget(sm);
}
void Menu::startLogin(Cards *window)
{
LoginMenu *lm = new LoginMenu(window);
window->setCentralWidget(lm);
}
void Menu::startRegister(Cards *window)
{
RegisterMenu *rm = new RegisterMenu(window);
window->setCentralWidget(rm);
}
menu.h
#ifndef MENU_H
#define MENU_H
#include <QWidget>
#include <QMainWindow>
#include <QGridLayout>
#include <QPushButton>
#include "cards.h"
#include "create_menu.h"
#include "search_menu.h"
#include "login_menu.h"
#include "register_menu.h"
class Cards;
class Menu : public QWidget
{
Q_OBJECT
public:
explicit Menu(Cards *window, QWidget *parent = 0);
public slots:
void startCreate(Cards *window);
void startSearch(Cards *window);
void startLogin(Cards *window);
void startRegister(Cards *window);
};
#endif // MENU_H