Hi.
Im learning qmdiarea, but I have problem.
What SIGNAL I need when I click buttom this do show new subwindow?
Thz.
Walter
Hi.
Im learning qmdiarea, but I have problem.
What SIGNAL I need when I click buttom this do show new subwindow?
Thz.
Walter
Sorry Walter, but I don't understand your post.
Do you have a button that shows a new MDI child? If you do, and your button is a QPushButton, then clicked() is the signal you're looking for.
Otherwise please be more specific and maybe post some code.
Regards
mainwindow.cpp
Qt Code:
mainWindow::mainWindow() { setupUi(this); mdiArea = new QMdiArea; setCentralWidget(mdiArea); setWindowTitle(tr("MDI Editor")); connect( menubar, SIGNAL(activated(int)), this, SLOT(actionNewWindow()) ); } void mainWindow::actionNewWindow() { QMdiSubWindow *subWindow1 = new QMdiSubWindow; subWindow1->setWindowTitle(tr("ZZZZ")); subWindow1->setAttribute(Qt::WA_DeleteOnClose); mdiArea->addSubWindow(subWindow1); }To copy to clipboard, switch view to plain text mode
I have this code, but I can do this SIGNAL? I have no error but no nothing to display.
Well, Thz marcel!!![]()
But you got it all wrong...
The menu bar is just the container for window menus.
These menus contain in turn menu items(actions).
What you have to do is create a menu and add an action to it( called New Window, if you will).
Then connect it's triggered signal to your slot.
For a detailed example, see the Menus example( Main Windows section) in the Qt Demos.
Regards
THz, I have read de source code for this example MENUS:
Qt Code:
connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));To copy to clipboard, switch view to plain text mode
I changed this in my code, but nothing.
Qt Code:
connect(menubar, SIGNAL(triggered()), this, SLOT(actionNewWindow())); or connect(menuFile, SIGNAL(triggered()), this, SLOT(actionNewWindow()));To copy to clipboard, switch view to plain text mode
Any way, I not understand, but no problem.
Thz
I think the only solution is to post the entire code and have someone look at it.
Regards
Ok attach the project.
Thz
Here's the corrected source:
Qt Code:
#include <QtGui> #include "mainwindow.h" ventanaPrincipal::ventanaPrincipal() { setupUi(this); mdiArea = new QMdiArea(this); setCentralWidget(mdiArea); setWindowTitle(tr("MDI Editor")); setMinimumSize(160, 160); resize(480, 320); connect(actionNueva_ventana, SIGNAL(triggered()), this, SLOT(nueva_ventana())); } void ventanaPrincipal::nueva_ventana() { QMdiSubWindow *subWindow1 = new QMdiSubWindow(this); subWindow1->setWindowTitle(tr("ZZZZ")); subWindow1->setAttribute(Qt::WA_DeleteOnClose); mdiArea->addSubWindow(subWindow1); subWindow1->show(); }To copy to clipboard, switch view to plain text mode
Your mistake is actually that you do not exactly know what it means to create menus with the designer.
The designer adds a menu action for every menu item that you create. The action is named after the menu item.
In your case, for the new window menu item you got the action actionNueva_ventana which was created automatically created for you.
This happens with all menu items.
I modified the slot name in order to make an explicit connect.
Take a good look at ui_uimain.h( generated by UIC from your UI file). Try to make the (logical)connections between what is in there and what you created in the UI.
Regards
Thz for your help!!
Now understand! In the Signal/Slot Editor (In designer) I created the connection:
Qt Code:
QObject::connect(actionNueva_ventana, SIGNAL(triggered()), vPrincipal, SLOT(actionNueva_ventana()));To copy to clipboard, switch view to plain text mode
Now work.
Well thz, and attach project for future people need this example.
Bye bye
Bookmarks