Problem with QDialog , its not closeing right away when pressing the x , how to make it NOT on top?
-
[quote author="umen242" date="1312788672"]Ok Thanks about the modeless problem i understood .
what about the connect / disconnect problem am i doing it right [/quote]Probably not. The code looks a bit weird to me. But it's hard to analyze without the complete classes and without knowing what you actually want to do.
-
So, why do you double the functionality? The signal mapper is only needed if the context menu needs to stay open during the execution of the slot called from the mapper.
The menu exec gives you back the selected menu entry:
@
QAction* selectedItem = ContextMenu.exec(globalPos);
@Just call the appropriate dialog according to the action returned by exec and abandon the QSignalMapper completely.
-
Try this:
@
void MainWindowContainer::ShowContextMenu(const QPoint& pos) // this is a slot
{
QPoint globalPos = ui.treeView_mainwindow->mapToGlobal(pos);
QAction* selectedItem = ContextMenu.exec(globalPos);if(selectedItem == OpenAction) { // do the open stuff } else if(selectedItem == EditAction) { // do the edit stuff }
}
@Problem with your approach is, that the actions fire while the menu is open - and during this time, the menu's event loop (call of exec) is still running and may interfere with the rest of the application.
-
Then you will have some code that attaches the data to the action anyways.
You could consider "dynamic properties":http://doc.qt.nokia.com/4.7/qobject.html#dynamic-properties attached to your QAction instances. You can read those from the returned QAction.