Details
-
Suggestion
-
Resolution: Done
-
P3: Somewhat important
-
4.8.3
-
None
-
6301d5e51b0c56d09b0bd1cb63f4908c3f8e2c70 dev 6/2019 (5.15)
Description
UIC has a logic to determine whether QMetaObject::connectSlotsByName()
should be generated or not. However, there is no way to switch off the
option "autoConnection" which specifies the generation of "connectSlotsByName()".
This function can be implemented by a few line of code such as:
-----------------------
— src/tools//uic/main.cpp.orig 2011-11-29 14:52:19.424979300 +0900
+++ src/tools/uic/main.cpp 2011-11-29 14:56:56.259798300 +0900
@@ -67,6 +67,7 @@
" -p, -no-protection disable header protection\n"
" -n, -no-implicit-includes disable generation of #include-directives\n"
" for forms generated by uic3\n"
+ " -a, -no-autoconnection disable generation of connectSlotsByName\n"
" -g <name> change generator\n"
"\n", appName);
}
@@ -120,6 +121,8 @@
return 1;
}
driver.option().translateFunction = QLatin1String(argv[arg]);
+ } else if (opt == QLatin1String("-a") || opt == QLatin1String("-no-autoconnection"))
else if (opt == QLatin1String("-g") || opt == QLatin1String("-generator")) {
++arg;
if (!argv[arg]) {
-----------------------
I'd like to write multiple ui file for a main window, one for the
top-level window and others for dock windows.
As a simple example, with two ui classes "ui" and "uiDock1" generated
by uic from two ui files, I can write initialization code as:
m_ui.setupUi(this);
m_uiDock1.setupUi(m_ui.dockPlaceHolder);
This code with normal uic works good for widgets on 'uiDock1', but for
signals from widgets on 'ui' connected twice to slots.
This problem can be avoided by:
1. generate ui codes with uic modified not to generate connectSlotsByName
2. calling connectSlotsByName manually such as:
m_ui.setupUi(this);
m_uiDock1.setupUi(m_ui.dockPlaceHolder);
QMetaObject::connectSlotsByName(this);