zoukankan      html  css  js  c++  java
  • 74.QT窗口实现类的封装

     1 #include "mainwindow.h"
     2 #include <QApplication>
     3 #include <windows.h>
     4 
     5 //定义一个窗口类
     6 class Window
     7 {
     8 public:
     9     MainWindow *p;
    10     int x;//大小
    11     int y;
    12     int cx;//位置
    13     int cy;
    14 
    15 public:
    16     Window()
    17     {
    18         p = new MainWindow();
    19         this->x = 0;
    20         this->y = 0;
    21         this->cx = 100;
    22         this->cy = 100;
    23         p->resize(this->x,this->y);
    24         p->move(this->cx,this->cy);
    25         p->show();
    26     }
    27     ~Window()
    28     {
    29         delete p;
    30     }
    31 
    32     void update()
    33     {
    34         p->resize(this->x,this->y);
    35         p->move(this->cx,this->cy);
    36     }
    37 
    38     void changesize(int a,int b)
    39     {
    40         this->x = a;
    41         this->y = b;
    42     }
    43 
    44     void changepos(int x,int y)
    45     {
    46         this->cx = x;
    47         this->cy = y;
    48     }
    49 };
    50 
    51 int main(int argc, char *argv[])
    52 {
    53     QApplication a(argc, argv);
    54 
    55     Window *my1 = new Window();
    56     while(1)
    57     {
    58         for(int i=100;i<800;i++)
    59         {
    60             my1->changesize(i,i);
    61             my1->update();
    62             Sleep(5);
    63         }
    64 
    65         for(int i=800;i>100;i--)
    66         {
    67             my1->changesize(i,i);
    68             my1->update();
    69             Sleep(5);
    70         }
    71     }
    72 
    73 
    74     return a.exec();
    75 }
  • 相关阅读:
    【JavaScript】--ajax
    【Django】--Models 和ORM以及admin配置
    【Django】--基础知识
    【jQuery】--图片轮播
    双系统 windows引导项添加
    LVM
    linux安全加固
    oracle 11G 配置侦听文件
    LVM
    《virtual san 最佳实践》节选 Virtual SAN的发展与现状
  • 原文地址:https://www.cnblogs.com/xiaochi/p/8576160.html
Copyright © 2011-2022 走看看