--- qt-everywhere-opensource-src-5.7.1/qtbase/src/tools/uic/main.cpp.orig	2017-11-09 10:36:46.747912177 +0100
+++ qt-everywhere-opensource-src-5.7.1/qtbase/src/tools/uic/main.cpp	2017-11-09 09:19:06.168666777 +0100
@@ -95,6 +95,11 @@
     generatorOption.setValueName(QStringLiteral("java|cpp"));
     parser.addOption(generatorOption);
 
+    QCommandLineOption nameFormatOption(QStringList() << QStringLiteral("f") << QStringLiteral("nameFormat"));
+    nameFormatOption.setDescription(QStringLiteral("Name formatter."));
+    nameFormatOption.setValueName(QStringLiteral("default|class"));
+    parser.addOption(nameFormatOption);
+
     QCommandLineOption idBasedOption(QStringLiteral("idbased"));
     idBasedOption.setDescription(QStringLiteral("Use id based function for i18n"));
     parser.addOption(idBasedOption);
@@ -112,6 +117,7 @@
     driver.option().translateFunction = parser.value(translateOption);
     driver.option().includeFile = parser.value(includeOption);
     driver.option().generator = (parser.value(generatorOption).toLower() == QLatin1String("java")) ? Option::JavaGenerator : Option::CppGenerator;
+    driver.option().nameFormat = parser.value(nameFormatOption).toLower() == QLatin1String("format") ? 1 : 0;
 
     QString inputFile;
     if (!parser.positionalArguments().isEmpty())
--- qt-everywhere-opensource-src-5.7.1/qtbase/src/tools/uic/driver.cpp.orig	2017-11-09 10:35:13.107613241 +0100
+++ qt-everywhere-opensource-src-5.7.1/qtbase/src/tools/uic/driver.cpp	2017-11-09 09:19:19.856709313 +0100
@@ -135,15 +135,22 @@
     return unique(name);
 }
 
-QString Driver::normalizedName(const QString &name)
+QString Driver::normalizedName(const QString &name, bool format)
 {
-    QString result = name;
-    QChar *data = result.data();
-    for (int i = name.size(); --i >= 0; ++data) {
-        if (!data->isLetterOrNumber())
-            *data = QLatin1Char('_');
+  bool allNumber = true;
+  QString result = name;
+  QChar *data = result.data();
+  for (int i = name.size(); --i >= 0; ++data)
+    {
+      if (allNumber && !data->isNumber())
+        allNumber = false;
+      if (!data->isLetterOrNumber())
+        *data = QLatin1Char('_');
     }
-    return result;
+  if (allNumber || format)
+    result = QLatin1String("idc_") + name;
+
+  return result;
 }
 
 QString Driver::unique(const QString &instanceName, const QString &className)
@@ -151,12 +158,26 @@
     QString name;
     bool alreadyUsed = false;
 
-    if (instanceName.size()) {
+    if (m_option.nameFormat)
+      {
+        int id = 1;
+        QString base = QLatin1String("instance") + className
+          + QLatin1String("_") + normalizedName(instanceName, m_option.nameFormat);
+        name = base;
+        
+        while (m_nameRepository.contains(name))
+          {
+            alreadyUsed = true;
+            name = base + QString::number(id++);
+          }
+      }
+    else if (instanceName.size())
+      {
         int id = 1;
         name = instanceName;
         name = normalizedName(name);
         QString base = name;
-
+        
         while (m_nameRepository.contains(name)) {
             alreadyUsed = true;
             name = base + QString::number(id++);
--- qt-everywhere-opensource-src-5.7.1/qtbase/src/tools/uic/driver.h.orig	2017-11-09 10:36:15.999814009 +0100
+++ qt-everywhere-opensource-src-5.7.1/qtbase/src/tools/uic/driver.h	2017-11-09 00:21:20.844830556 +0100
@@ -73,7 +73,7 @@
     static QString headerFileName(const QString &fileName);
     QString headerFileName() const;
 
-    static QString normalizedName(const QString &name);
+    static QString normalizedName(const QString &name, bool format = false);
     static QString qtify(const QString &name);
     QString unique(const QString &instanceName=QString(),
                    const QString &className=QString());
--- qt-everywhere-opensource-src-5.7.1/qtbase/src/tools/uic/option.h.orig	2017-11-09 10:36:29.915858437 +0100
+++ qt-everywhere-opensource-src-5.7.1/qtbase/src/tools/uic/option.h	2017-11-09 00:11:31.494896010 +0100
@@ -52,6 +52,7 @@
     unsigned int limitXPM_LineLength : 1;
     unsigned int implicitIncludes: 1;
     unsigned int idBased: 1;
+    unsigned int nameFormat:1;
     Generator generator;
 
     QString inputFile;
