user2893054
user2893054

Reputation: 85

How to use QmainWindow inside a QWidget?

I am facing a problem, I have created an application using QmainWindow it is having tool bars, & statusbars. Now I have to add this application to another application which is derived from a another QMainWindow . Now I want to have my main Window inside this Main Window . How to do this Can we have QMainWindow inside Another QmainWindow or inside a QWidget? please hepl me .

Upvotes: 5

Views: 5692

Answers (2)

vahancho
vahancho

Reputation: 21220

I would write something like:

QMainWindow inside of another QMainWindow

QMainWindow *mainWindow = new QMainWindow;
QMainWindow *subWindow = new QMainWindow(mainWindow);
// .. some configuration
mainWindow->setCentralWidget(subWindow);

QMainWindow inside of a QWidget

QWidget *mainWindow = new QWidget;
QMainWindow *subWindow = new QMainWindow(mainWindow);
// .. some configuration
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(subWindow);
mainWindow->setLayout(layout);

Upvotes: 7

aaa
aaa

Reputation: 499

you can use this:

void QApplication::setActiveWindow(QWidget * active)

to set the widget (your main window) as the main window.

Upvotes: -2

Related Questions