Skip to content

Commit

Permalink
增加Qt使用uic的例子
Browse files Browse the repository at this point in the history
  • Loading branch information
duyanning committed Jul 29, 2019
1 parent fd1002f commit f885519
Show file tree
Hide file tree
Showing 3 changed files with 212 additions and 0 deletions.
108 changes: 108 additions & 0 deletions examples/hello-qt-uic/gotocelldialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/********************************************************************************
** Form generated from reading UI file 'gotocelldialog.ui'
**
** Created by: Qt User Interface Compiler version 5.12.3
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/

#ifndef GOTOCELLDIALOG_H
#define GOTOCELLDIALOG_H

#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QLabel>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QSpacerItem>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QWidget>

QT_BEGIN_NAMESPACE

class Ui_GoToCellDialog
{
public:
QVBoxLayout *vboxLayout;
QHBoxLayout *hboxLayout;
QLabel *label;
QLineEdit *lineEdit;
QHBoxLayout *hboxLayout1;
QSpacerItem *spacerItem;
QPushButton *okButton;
QPushButton *cancelButton;

void setupUi(QWidget *GoToCellDialog)
{
if (GoToCellDialog->objectName().isEmpty())
GoToCellDialog->setObjectName(QString::fromUtf8("GoToCellDialog"));
GoToCellDialog->resize(190, 94);
vboxLayout = new QVBoxLayout(GoToCellDialog);
vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
hboxLayout = new QHBoxLayout();
hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
label = new QLabel(GoToCellDialog);
label->setObjectName(QString::fromUtf8("label"));

hboxLayout->addWidget(label);

lineEdit = new QLineEdit(GoToCellDialog);
lineEdit->setObjectName(QString::fromUtf8("lineEdit"));

hboxLayout->addWidget(lineEdit);


vboxLayout->addLayout(hboxLayout);

hboxLayout1 = new QHBoxLayout();
hboxLayout1->setObjectName(QString::fromUtf8("hboxLayout1"));
spacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);

hboxLayout1->addItem(spacerItem);

okButton = new QPushButton(GoToCellDialog);
okButton->setObjectName(QString::fromUtf8("okButton"));
okButton->setEnabled(false);

hboxLayout1->addWidget(okButton);

cancelButton = new QPushButton(GoToCellDialog);
cancelButton->setObjectName(QString::fromUtf8("cancelButton"));

hboxLayout1->addWidget(cancelButton);


vboxLayout->addLayout(hboxLayout1);

#ifndef QT_NO_SHORTCUT
label->setBuddy(lineEdit);
#endif // QT_NO_SHORTCUT
QWidget::setTabOrder(lineEdit, okButton);
QWidget::setTabOrder(okButton, cancelButton);

retranslateUi(GoToCellDialog);

okButton->setDefault(true);


QMetaObject::connectSlotsByName(GoToCellDialog);
} // setupUi

void retranslateUi(QWidget *GoToCellDialog)
{
GoToCellDialog->setWindowTitle(QApplication::translate("GoToCellDialog", "Go to Cell", nullptr));
label->setText(QApplication::translate("GoToCellDialog", "&Cell Location:", nullptr));
okButton->setText(QApplication::translate("GoToCellDialog", "OK", nullptr));
cancelButton->setText(QApplication::translate("GoToCellDialog", "Cancel", nullptr));
} // retranslateUi

};

namespace Ui {
class GoToCellDialog: public Ui_GoToCellDialog {};
} // namespace Ui

QT_END_NAMESPACE

#endif // GOTOCELLDIALOG_H
79 changes: 79 additions & 0 deletions examples/hello-qt-uic/gotocelldialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<ui version="4.0" >
<class>GoToCellDialog</class>
<widget class="QWidget" name="GoToCellDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>190</width>
<height>94</height>
</rect>
</property>
<property name="windowTitle" >
<string>Go to Cell</string>
</property>
<layout class="QVBoxLayout" >
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="label" >
<property name="text" >
<string>&amp;Cell Location:</string>
</property>
<property name="buddy" >
<cstring>lineEdit</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit" />
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="okButton" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>OK</string>
</property>
<property name="default" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton" >
<property name="text" >
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>
<tabstop>lineEdit</tabstop>
<tabstop>okButton</tabstop>
<tabstop>cancelButton</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
25 changes: 25 additions & 0 deletions examples/hello-qt-uic/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <QApplication>
#include <QDialog>

#include "gotocelldialog.h"

// cpps-make ui_gotocelldialog.h : gotocelldialog.ui // uic gotocelldialog.ui -o gotocelldialog.h

// vc-extra-compile-flags: -IF:\vcpkg\installed\x86-windows\include\QtWidgets

/* cpps-make
ui_gotocelldialog.h : gotocelldialog.ui
uic gotocelldialog.ui -o gotocelldialog.h
*/

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

Ui::GoToCellDialog ui;
QDialog *dialog = new QDialog;
ui.setupUi(dialog);
dialog->show();

return app.exec();
}

0 comments on commit f885519

Please sign in to comment.