第二章 创建对话框 2.3快速设计对话框

本节介绍如何利用Qt Designer进行可视化设计,创建gotocell对话框。通过Qt Creator新建项目并集成.ui文件,但发现编译后未生成.h文件。解决方案是利用qmake的uic.exe工具在命令行生成头文件。生成的类没有基类,仅包含初始化函数setupUi()。为实现更多功能,创建一个新类继承自QDialog和生成的Ui类。
摘要由CSDN通过智能技术生成

这一小节利用Qt Designer提供的可视化的设计能力,快速设计自己的窗口。

将创建一个gotocell的对话框,

       按照书上的步骤,我用Qt designer生成了一个 .ui文件,我安装的是Qt 4.8.5,用的是ide 环境 Qt creator,可以新建巍项目让把ui文件直接放进项目里使用,但我发现编译之后ui文件并没有生成.h文件,所以我上网找了,后来发现可行的方法是利用qt安装目录里qmake文件夹里的uic.exe ,在命令行窗口下调用uic。 输入的命令为

uic -o  ××.h ××.ui

uic和ui文件必须在一个目录下,然后会生成h文件。

ui_gotocelldialog.h如下

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

#ifndef DS_H
#define DS_H

#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QDialog>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QVBoxLayout>

QT_BEGIN_NAMESPACE

class Ui_GoTocellDialog
{
public:
    QVBoxLayout *verticalLayout;
    QHBoxLayout *horizontalLayout;
    QLabel *label;
    QLineEdit *lin
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值