yapatel
9th April 2014, 01:46
Hi -
I have a QT4 application that uses the MenuBar with the typical menus (File, Edit, Settings, etc). I want to add a "Windows" menu to it - with the function of being able to show the open MdiSubWindows in my MdiArea.
I tried
// Clear previous entries
windowsMenu->clear ();
// Add default options
windowsMenu->addAction(tr("Cascade"),mdiArea,SLOT(cascadeSubWindows()));
windowsMenu->addAction(tr("Tile"),mdiArea,SLOT(tileSubWindows()));
windowsMenu->addSeparator();
// Get list of open subwindows in Mdi Area
QList<QMdiSubWindow *> subWindows = mdiArea->subWindowList();
// Make sure it isn't empty
if(subWindows.isEmpty()){
return;
}
// Create windows list based off of what's open
for(int i = 0; i < subWindows.size(); i++){
QMdiSubWindow *child = subWindows.at(i);
windowsMenu->addAction(child->widget()->windowTitle(),this,SLOT(windowsMenuActivated(int)) );
}
That compiles and generates a list of open MdiSubWindows as I want. The trouble I am having is using that created menu to then select/switch to one of those windows - and I think the problem is in the following line:
windowsMenu->addAction(child->widget()->windowTitle(),this,SLOT(windowsMenuActivated(int)) );
The windowsMenuActivated(int) slot is defined as:
void MainWindow::windowsMenuActivated(int id) {
// Get list of open subwindows in Mdi Area
QList<QMdiSubWindow *> subWindows = mdiArea->subWindowList();
// Make sure it isn't empty
if(subWindows.isEmpty()){
return;
}
// Set active selected window
mdiArea->setActiveSubWindow(subWindows.at(id));
}
This all compiles fine, but when I run the program, I get:
QObject::connect: Incompatible sender/receiver arguments
QAction::triggered(bool) --> MainWindow::windowsMenuActivated(int)
All I want to do is set the selected window (from the windowsMenu) to be the active mdnsubwindow...
I have a QT4 application that uses the MenuBar with the typical menus (File, Edit, Settings, etc). I want to add a "Windows" menu to it - with the function of being able to show the open MdiSubWindows in my MdiArea.
I tried
// Clear previous entries
windowsMenu->clear ();
// Add default options
windowsMenu->addAction(tr("Cascade"),mdiArea,SLOT(cascadeSubWindows()));
windowsMenu->addAction(tr("Tile"),mdiArea,SLOT(tileSubWindows()));
windowsMenu->addSeparator();
// Get list of open subwindows in Mdi Area
QList<QMdiSubWindow *> subWindows = mdiArea->subWindowList();
// Make sure it isn't empty
if(subWindows.isEmpty()){
return;
}
// Create windows list based off of what's open
for(int i = 0; i < subWindows.size(); i++){
QMdiSubWindow *child = subWindows.at(i);
windowsMenu->addAction(child->widget()->windowTitle(),this,SLOT(windowsMenuActivated(int)) );
}
That compiles and generates a list of open MdiSubWindows as I want. The trouble I am having is using that created menu to then select/switch to one of those windows - and I think the problem is in the following line:
windowsMenu->addAction(child->widget()->windowTitle(),this,SLOT(windowsMenuActivated(int)) );
The windowsMenuActivated(int) slot is defined as:
void MainWindow::windowsMenuActivated(int id) {
// Get list of open subwindows in Mdi Area
QList<QMdiSubWindow *> subWindows = mdiArea->subWindowList();
// Make sure it isn't empty
if(subWindows.isEmpty()){
return;
}
// Set active selected window
mdiArea->setActiveSubWindow(subWindows.at(id));
}
This all compiles fine, but when I run the program, I get:
QObject::connect: Incompatible sender/receiver arguments
QAction::triggered(bool) --> MainWindow::windowsMenuActivated(int)
All I want to do is set the selected window (from the windowsMenu) to be the active mdnsubwindow...