zoukankan      html  css  js  c++  java
  • 31.QT坐标系

    • dialog.h
       1 #ifndef DIALOG_H
       2 #define DIALOG_H
       3 
       4 #include <QDialog>
       5 #include <QLabel>
       6 #include <QGridLayout>
       7 #include <QMouseEvent>
       8 #include <QEvent>
       9 
      10 namespace Ui {
      11 class Dialog;
      12 }
      13 
      14 class Dialog : public QDialog
      15 {
      16     Q_OBJECT
      17 
      18 public:
      19     explicit Dialog(QWidget *parent = 0);
      20     ~Dialog();
      21 
      22 private:
      23     Ui::Dialog *ui;
      24 
      25     void moveEvent(QMoveEvent *event);
      26     void resizeEvent(QResizeEvent *event);
      27 
      28 public:
      29     void show1();
      30 };
      31 
      32 #endif // DIALOG_H
    • dialog.cpp
       1 #include "dialog.h"
       2 #include "ui_dialog.h"
       3 #include <QDebug>
       4 
       5 Dialog::Dialog(QWidget *parent) :
       6     QDialog(parent),
       7     ui(new Ui::Dialog)
       8 {
       9     ui->setupUi(this);
      10 }
      11 
      12 Dialog::~Dialog()
      13 {
      14     delete ui;
      15 }
      16 
      17 void Dialog::moveEvent(QMoveEvent *event)
      18 {
      19     qDebug() << "1234"<<endl;
      20     show1();
      21 }
      22 
      23 void Dialog::resizeEvent(QResizeEvent *event)
      24 {
      25     qDebug() << "1234"<<endl;
      26     show1();
      27 }
      28 
      29 void Dialog::show1()
      30 {
      31     QString infoall;
      32     QString x;
      33     x.sprintf("x()=%d",this->x());
      34     infoall = infoall +x + "
      ";
      35 
      36     QString y;
      37     y.sprintf("y()=%d",this->y());
      38     infoall = infoall +y + "
      ";
      39 
      40     QString width;
      41     width.sprintf("width=%d",this->width());
      42     infoall = infoall +width + "
      ";
      43 
      44     QString height;
      45     height.sprintf("height=%d",this->height());
      46     infoall = infoall +height + "
      ";
      47     ui->textEdit->setText(infoall);
      48 }
  • 相关阅读:
    搭建 structs2 环境
    数据库基础
    好书推荐整理
    Java 完美判断中文字符
    中文在unicode中的编码范围
    [转载]爬虫的自我解剖(抓取网页HtmlUnit)
    web应用配置
    简单的Java Web服务器
    dos基本命令
    Unrecognized Windows Sockets error: 0: JVM_Bind
  • 原文地址:https://www.cnblogs.com/xiaochi/p/8794062.html
Copyright © 2011-2022 走看看