Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-27866

UIC needs to implement a command line option to disable "autoConnection"

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • P3: Somewhat important
    • 5.15
    • 4.8.3
    • Build tools: uic
    • 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"))

      { + driver.option().autoConnection = false; }

      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);

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            yos Tomoaki Yoshida
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes