52 QXmlStreamReader reader;
54 ui = parseUiFile(reader);
59 if (
DomIncludes *includes = ui->elementIncludes()) {
60 const auto incls = includes->elementInclude();
66 fprintf(stdout,
"%s\n",
file.toLocal8Bit().constData());
71 const auto elementCustomWidget = customWidgets->elementCustomWidget();
78 fprintf(stdout,
"%s\n",
file.toLocal8Bit().constData());
88void Uic::writeCopyrightHeaderCpp(
const DomUI *ui)
const
90 QString comment = ui->elementComment();
92 out <<
"/*\n" << comment <<
"\n*/\n\n";
94 out <<
"/********************************************************************************\n";
97 out <<
"** Created by: Qt User Interface Compiler version " << QT_VERSION_STR <<
"\n";
99 out <<
"** WARNING! All changes made in this file will be lost when recompiling UI file!\n";
100 out <<
"********************************************************************************/\n\n";
108 return c == u
'/' ||
c == u
'*';
119void Uic::writeCopyrightHeaderPython(
const DomUI *ui)
const
121 QString comment = ui->elementComment();
124 for (
const auto &
line : lines) {
138 out <<
language::repeat(80,
'#') <<
"\n## Form generated from reading UI file '"
140 <<
"'\n##\n## Created by: Qt User Interface Compiler version " << QT_VERSION_STR
141 <<
"\n##\n## WARNING! All changes made in this file will be lost when recompiling UI file!\n"
149 const QXmlStreamAttributes attributes = reader.attributes();
150 const auto versionAttribute =
"version"_L1;
151 if (!attributes.hasAttribute(versionAttribute))
153 const QStringView version = attributes.value(versionAttribute);
157DomUI *Uic::parseUiFile(QXmlStreamReader &reader)
161 const auto uiElement =
"ui"_L1;
163 if (
reader.readNext() == QXmlStreamReader::StartElement) {
176 reader.raiseError(
"Unexpected element "_L1 +
reader.name().toString());
193 QScopedPointer<DomUI> ui;
195 QXmlStreamReader reader;
197 ui.reset(parseUiFile(reader));
203 double version = ui->attributeVersion().toDouble();
205 fprintf(stderr,
"uic: File generated with too old version of Qt Widgets Designer\n");
213 fprintf(stderr,
"uic: File is not a \"c++\" ui file, language=%s\n",
qPrintable(
language));
217 return write(ui.data());
222 if (!ui || !ui->elementWidget())
228 out <<
"# -*- coding: utf-8 -*-\n\n";
233 writeCopyrightHeaderCpp(ui);
236 writeCopyrightHeaderPython(ui);
242 writeHeaderProtectionStart();
246 pixFunction = ui->elementPixmapFunction();
247 if (pixFunction ==
"QPixmap::fromMimeSource"_L1 || pixFunction ==
"qPixmapFromMimeSource"_L1) {
248 fprintf(stderr,
"%s: Warning: Obsolete pixmap function '%s' specified in the UI file.\n",
259 writeIncludes.acceptUI(ui);
266 writeImports.acceptUI(ui);
274 writeHeaderProtectionEnd();
279void Uic::writeHeaderProtectionStart()
282 out <<
"#ifndef " <<
h <<
"\n"
283 <<
"#define " <<
h <<
"\n";
286void Uic::writeHeaderProtectionEnd()
289 out <<
"#endif // " <<
h <<
"\n";
295 u
"QRadioButton"_s, u
"QToolButton"_s,
296 u
"QCheckBox"_s, u
"QPushButton"_s,
297 u
"QCommandLinkButton"_s
305 u
"QStackedWidget"_s, u
"QToolBox"_s,
306 u
"QTabWidget"_s, u
"QScrollArea"_s,
307 u
"QMdiArea"_s, u
"QWizard"_s,
317 u
"QMenu"_s, u
"QPopupMenu"_s
void acceptUI(DomUI *node) override
void setUseIdBasedTranslations(bool u)
static QString headerFileName(const QString &fileName)
void setFileName(const QString &name)
Sets the name of the file.
\inmodule QtCore \reentrant
QString errorString() const
Returns a human readable description of the last error that occurred.
void setDevice(QIODevice *device)
Sets QImageReader's device to device.
Q_CORE_EXPORT double toDouble(bool *ok=nullptr) const
Returns the string view converted to a double value.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QStringList split(const QString &sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the string into substrings wherever sep occurs, and returns the list of those strings.
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
void clear()
Clears the contents of the string and makes it null.
qsizetype size() const noexcept
Returns the number of characters in this string.
QString right(qsizetype n) const &
bool isButton(const QString &className) const
bool write(QIODevice *in)
const CustomWidgetsInfo * customWidgetsInfo() const
bool isMenu(const QString &className) const
bool isContainer(const QString &className) const
Combined button and popup list for selecting options.
QImageReader reader("image.png")
[1]
static QString header(const QString &name)
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLfloat GLfloat GLfloat GLfloat h
#define qPrintable(string)
QT_BEGIN_NAMESPACE typedef uchar * output
const char className[16]
[1]
QTextStream out(stdout)
[7]
void acceptUI(DomUI *node) override
unsigned int headerProtection
QString messagePrefix() const
unsigned int copyrightHeader
void acceptUI(DomUI *node) override
void acceptUI(DomUI *node) override
static double versionFromUiAttribute(QXmlStreamReader &reader)
static int leadingCppCommentCharCount(QStringView s)
static bool isCppCommentChar(QChar c)