From 2d6b7d27e84ddd9127e7adca7cfcbb99b8c90bb0 Mon Sep 17 00:00:00 2001 From: amazing-username Date: Sat, 25 Mar 2017 16:26:15 -0500 Subject: [PATCH] Switch from custom layout to the QMainWindow layout scheme --- MessagingControls.cpp | 42 +++++++++++++++++++++++++++++++----------- MessagingControls.h | 18 ++++++++++++++---- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/MessagingControls.cpp b/MessagingControls.cpp index 7febd76..7e5b5af 100644 --- a/MessagingControls.cpp +++ b/MessagingControls.cpp @@ -5,15 +5,15 @@ #include "MessagingControls.h" -MessagingControls::MessagingControls(QWidget* parent) : QDialog(parent) +MessagingControls::MessagingControls() { /** * Initialize controls */ - QVBoxLayout* everything = new QVBoxLayout; + //QVBoxLayout* everything = new QVBoxLayout; //menuStuff = new QMenuBar; - mainWindow = new QMainWindow; + //mainWindow = new QMainWindow; lblOfEncryptedBox = new QLabel(tr("Message: ")); @@ -23,23 +23,28 @@ MessagingControls::MessagingControls(QWidget* parent) : QDialog(parent) encryptionButon = new QPushButton; //Adding lbl and line edit - QHBoxLayout* lblAndLineEdit = new QHBoxLayout; - lblAndLineEdit->addWidget(lblOfEncryptedBox); - lblAndLineEdit->addWidget(textToEncrypt); + //QHBoxLayout* lblAndLineEdit = new QHBoxLayout; + //lblAndLineEdit->addWidget(lblOfEncryptedBox); + //lblAndLineEdit->addWidget(textToEncrypt); //Adding button - QHBoxLayout* button = new QHBoxLayout; - button->addWidget(encryptionButon); + //QHBoxLayout* button = new QHBoxLayout; + //button->addWidget(encryptionButon); //Add everything //everything->addLayout(menuStuff); - everything->addLayout(lblAndLineEdit); - everything->addLayout(button); + //everything->addLayout(lblAndLineEdit); + //everything->addLayout(button); + + createMenus(); QDockWidget* lblAndArea = new QDockWidget(tr("Dock Widget")); lblAndArea->setWidget(textToEncrypt); + //lblAndArea->setWidget(lblOfEncryptedBox); - mainWindow->addDockWidget(Qt::LeftDockWidgetArea, lblAndArea); + addDockWidget(Qt::LeftDockWidgetArea, lblAndArea); + + //mainWindow->addDockWidget(Qt::LeftDockWidgetArea, lblAndArea); //mainWindow->addDockWidget(lblAndArea); //mainWindow->addDockWidget(textToEncrypt); //mainWindow->addDockWidget(encryptionButon); @@ -60,3 +65,18 @@ MessagingControls::~MessagingControls() //delete encryptedBox; } + + +void MessagingControls::createMenus() +{ + fileMenu = menuBar()->addMenu(tr("File")); + editMenu = menuBar()->addMenu(tr("Edit")); + + closeApplication = new QAction(tr("Quit Application")); + keyEdit = new QAction(tr("Key Edit")); + + fileMenu->addAction(closeApplication); + + editMenu->addAction(keyEdit); + +} diff --git a/MessagingControls.h b/MessagingControls.h index da8db9d..3c1669e 100644 --- a/MessagingControls.h +++ b/MessagingControls.h @@ -8,6 +8,8 @@ #include #include #include +#include +#include class QLabel; class QLineEdit; @@ -15,26 +17,34 @@ class QTextEdit; class QPushButton; class QMenuBar; class QMainWindow; +class QMenu; +class QAction; -class MessagingControls : public QDialog +class MessagingControls : public QMainWindow { Q_OBJECT public: - MessagingControls(QWidget* parent = 0); + MessagingControls(); ~MessagingControls(); + + signals: private slots: private: + void createMenus(); + QLineEdit* encryptedBox; QLabel* lblOfEncryptedBox; QTextEdit* textToEncrypt; QPushButton* encryptionButon; - QMenuBar* menuStuff; - QMainWindow* mainWindow; + QMenu* fileMenu; + QMenu* editMenu; + QAction* closeApplication; + QAction* keyEdit; }; #endif