Thank you Lykurg and Santosh for your reply.
I can now have a set of buttons vertically alligned but they open to a separate window (ie. one mainwindow with a menubar that I created
by typing in IDE, and another one with 5 buttons). Please see the code below. If I try to open in the main window I can't see these 5 buttons. However, with QHBoxLayout they appear in the main window but with very small size and sitting on top of the menubar.
Also, I suppose I need to somehow connect these buttons with the parent menu for ex. "Live Traffic" button. Because when this particular button is selected/pressed the corresponding buttons should vertically appear on the window (left side).
Santosh, I also tried QStackedLayout...but it also opens a separate box outside the main. Perhaps I am not doing it right.
I appreciate your time.
#include "mainwindow.h"
#include <QApplication>
#include <QWidget>
#include <QVBoxLayout>
#include <QPushButton>
int main(int argc, char *argv[])
{
MainWindow w;
//QWidget *window = new QWidget(&w);
layout->addWidget(button1);
layout->addWidget(button2);
layout->addWidget(button3);
layout->addWidget(button4);
layout->addWidget(button5);
window->setLayout(layout);
window->show();
w.show();
return app.exec();
}
#include "mainwindow.h"
#include <QApplication>
#include <QWidget>
#include <QVBoxLayout>
#include <QPushButton>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow w;
QWidget *window = new QWidget();
//QWidget *window = new QWidget(&w);
QPushButton *button1 = new QPushButton("Total Traffic");
QPushButton *button2 = new QPushButton("Network Layer");
QPushButton *button3 = new QPushButton("Transport Layer");
QPushButton *button4 = new QPushButton("Application Layer");
QPushButton *button5 = new QPushButton ("Host");
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget(button1);
layout->addWidget(button2);
layout->addWidget(button3);
layout->addWidget(button4);
layout->addWidget(button5);
window->setLayout(layout);
window->show();
w.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks