View Full Version : Parent Child for window
febil
31st March 2009, 13:20
Hi all,
I have a doubt.
I have 2 QMainWindow. Can i make a one QMainWindow as the child of another QMainWindow???
spirit
31st March 2009, 13:27
yes, you can.
Test::Test(QWidget *parent)
: QMainWindow(parent)
{
QTabWidget *tabWidget = new QTabWidget();
QWidget *page = new QWidget();
QHBoxLayout *layout = new QHBoxLayout(page);
m_pbNewWindow = new QPushButton(tr("New window"));
layout->addWidget(m_pbNewWindow);
tabWidget->addTab(page, tr("Test"));
connect(m_pbNewWindow, SIGNAL(clicked()), SLOT(newWindow()));
setCentralWidget(tabWidget);
}
void Test::newWindow()
{
Test *test = new Test(this);
test->setAttribute(Qt::WA_DeleteOnClose);
test->show();
}
talk2amulya
31st March 2009, 13:31
technically yes, but they wont come one inside another. plus what is your motivation for this atrocity :)
febil
31st March 2009, 17:45
ok...can it be displayed as a pop-up window. i.e. if i click a button from the parent QMainWindow, can pop-up the 2nd QMainWindow??
spirit
31st March 2009, 17:47
don't my example work?
talk2amulya
31st March 2009, 18:04
ok...can it be displayed as a pop-up window. i.e. if i click a button from the parent QMainWindow, can pop-up the 2nd QMainWindow??
yes that can happen of course but why a window..why not a widget? would you like to explain why u need such a behaviour. Possibly there might be more efficient ways of attaining your goals
febil
1st April 2009, 05:00
Dear Spirit, i will try based on ur example.
Dear talk2amulya, i have a mainwindow and when i clicked a button from the main window, i need to display another window. This window contains menu, toolbar, tool buttons etc... so i think i need to use QMainWindow.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.