Chinaunix首页 | 论坛 | 博客
  • 博客访问: 302227
  • 博文数量: 63
  • 博客积分: 1482
  • 博客等级: 上尉
  • 技术积分: 1185
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-12 19:06
个人简介

hello world!

文章分类

全部博文(63)

分类: C/C++

2011-08-16 17:06:19

        做过以下了个程序子类化,主要记录如下:
 
  1. //文件splaylabelForm.h
  2. #ifndef _SplayLabelForm_
  3. #define _SplayLabelForm_

  4. #include <QtGui> //头文件
  5. #include <QtSql> //数据库相关头文件
  6. #include "databaseview.h" //自编写的数据库连接头文件

  7. class SplayLabelForm:public QDialog //定义SplayLabelForm成为QDialog的子类
  8. {
  9.     Q_OBJECT
  10. public: //公共
  11.     SplayLabelForm(QWidget *parent=0); //指定其父窗口部件,为0则没有。
  12.         …..
  13. private: //私有
  14.     void createMainwindow();
  15.          …….
  16.      QTabWidget *pageTabWidget;
  17.      QGroupBox *groupBox;
  18.                   ...

  19. signals: //此处增加自定义信号
  20.          void refreshTableSignal(QTableView *curView);
  21.                 ……

  22. private slots: //此处增加自定义槽
  23.         void refreshTableAll();
  24.                 ……
  25. };
  26. #endif // _SplayLabelForm_

  27. //文件splayLabelFrom.cpp
  28. #include <QtGui>
  29. #include <QtSql>
  30. #include "splayLabelForm.h"

  31. static int curRowIndex = -1; //激活的当前类别中的行
  32. static int nPage=1; //动态类别个数
  33. static int nCurPage=1; //类别个数
  34. static int nCurScroller=0; //翻页时的当时滑动条位置
  35. static int pageValue = 10; // 一页显示条数
  36. SplayLabelForm::SplayLabelForm(QWidget *parent) : QDialog(parent)
  37. {
  38.     createMainwindow(); //调用函数
  39.     ……. //此处填写代码
  40. }
  41. void SplayLabelForm::refreshTableAll()
  42. {
  43.     ….. //此处填写代码
  44. }

  45. //文件main.cpp 测试函数
  46. #include <QtGui>
  47. #include "splayLabelForm.h"

  48. int main(int argc,char *argv[])
  49. {
  50.     QApplication myApp(argc,argv);
  51.     QTextCodec::setCodecForTr(QTextCodec::codecForLocale()); //显示中文
  52.     SplayLabelForm *myForm=new SplayLabelForm; //使用自定义类

  53.     myForm->resize(800,480); //从QDialog中继承的函数,设置显示窗口大小为800x480
  54.     myForm->show(); //刚建立窗口时是隐藏的,在此显示出来
  55.     return myApp.exec(); //进入消息循环
  56. }
编译过程
      # qmake  -project
      # qmake
      #  make
      # ./“执行文件名”
 
运行时将弹出一个空界面:
 
 

一些常用类参考:

QApplication 应用程序类

QLabel 标签类

QPushButton 按钮类

QButtonGroup 按钮组合类

QGroupBox 群组类

QDateTimeEdit 日期时间编辑框类

QLineEdit 行编辑框类

QTextEdit 文本编辑框类

QComboBox 组合框类

QProgressBar 进度条类

QLCDNumber 数字显示框类

QScrollBar 滚动条类

QSpinBox 微调框类

QSlider 滑动条类

QIconView 图标视图类

QListView 列表视图类

QListBox 列表框类

QTable 表格类

QValidator 有效性检查类

QImage 图像类

QMainWindow 主窗口类

QPopupMenu 弹出性菜单类

QMenuBar 菜单栏类

QToolButton 工具按钮类

QToolTip 提示类

QWhatsThis 这是什么类

QAction 动作类

QHBoxLayout 水平布局类

QVBoxLayout 垂直布局类

QGridLayout 表格布局类

QT对话框类

QMessageBox 消息对话框类

QProgressDialog 进度条对话框类

QWizard 向导对话框类

QFileDialog 文件对话框类

QColorDialog 颜色对话框类

QFontDialog 字体对话框类

QPrintDialog 打印对话框类

 

QT4 Class Chart(详细类图)

 Qt41 Class Chart.pdf   

阅读(2663) | 评论(2) | 转发(0) |
给主人留下些什么吧!~~

2011-08-17 15:48:59

http://www.211sun.com/
http://www.83193999.com/
信用卡办理 校园兼职 大学生生活网 福建旅游 大学生二手交易 信用卡 中国银行信用卡大学生信用卡  信用卡办理

2011-08-17 15:48:03

<a href="http://www.211sun.com/"><font color="#000000">信用卡办理</font></a>
<a href="http://www.211sun.com/"><font color="#000000">校园兼职</font></a>
<a href="http://www.211sun.com/"&