【專題7:qt上位機詳解】 之 【4.信號與槽 - 界面是如何生成c++代碼的(重點)】

一個默默耕耘的工程師…

各專題目錄
【專題1:工作兩年再學嵌入式】
【專題2:freertos系統詳解】
【專題3:從0到1寫嵌入式操作系統】
【專題4:直流無刷電機控制】
【專題5:從0到1寫bootloader、iap升級和產品量產】
【專題6:mcu硬件電路設計】
【專題7:qt上位機詳解】
【專題8:linux應用及qt移植】
【專題9:從linux內核借鑑寫代碼的思路】
【專題10:面向對象和事件驅動】
【專題11:從0到1開發儀表】
【專題12:常用複雜模塊從0到1】
【專題13:讀書筆記】

  QT會自動將界面生成一個ui_widget.h的文件,雖然是.h文件,但裏面也包含了所有源碼。在界面中所有的控件的設置代碼,都在該文件裏面。當不知道怎麼通過代碼來設置控件的屬性時,可以直接參考該.h文件來設置。
在這裏插入圖片描述

/********************************************************************************
** Form generated from reading UI file 'widget.ui'
**
** Created by: Qt User Interface Compiler version 5.9.0
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/

#ifndef UI_WIDGET_H
#define UI_WIDGET_H

#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QWidget>

QT_BEGIN_NAMESPACE

class Ui_Widget
{
public:
    QPushButton *closeButton;
    QPushButton *viewSlotButton;

    void setupUi(QWidget *Widget)
    {
        if (Widget->objectName().isEmpty())
            Widget->setObjectName(QStringLiteral("Widget"));
        Widget->resize(939, 499);
        closeButton = new QPushButton(Widget);
        closeButton->setObjectName(QStringLiteral("closeButton"));
        closeButton->setGeometry(QRect(270, 240, 93, 28));
        viewSlotButton = new QPushButton(Widget);
        viewSlotButton->setObjectName(QStringLiteral("viewSlotButton"));
        viewSlotButton->setGeometry(QRect(130, 240, 93, 28));

        retranslateUi(Widget);
        QObject::connect(closeButton, SIGNAL(clicked()), Widget, SLOT(close()));
        QObject::connect(viewSlotButton, SIGNAL(clicked()), Widget, SLOT(ViewSlot()));

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

    void retranslateUi(QWidget *Widget)
    {
        Widget->setWindowTitle(QApplication::translate("Widget", "Widget", Q_NULLPTR));
        closeButton->setText(QApplication::translate("Widget", "\345\205\263\351\227\255", Q_NULLPTR));
        viewSlotButton->setText(QApplication::translate("Widget", "viewSlot", Q_NULLPTR));
    } // retranslateUi

};

namespace Ui {
    class Widget: public Ui_Widget {};
} // namespace Ui

QT_END_NAMESPACE

#endif // UI_WIDGET_H
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章