mainwindows.cpp

 //显示主窗口和另外一个窗口
 #if 1
    TestWidget*w=new TestWidget;
    w->show();
 #else
    TestWidget*w=new TestWidget(this);
 #endif

#if 0
    //创建对话框窗口
    TestDialog*dlg=new TestDialog (this);
    dlg->show();
#else
    //模态,阻塞
    TestDialog*dlg=new TestDialog (this);
    dlg->exec();
#endif

  

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "testwidget.h"
#include "testdialog.h"
#include<QPushButton>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->move(10,10);
    QPushButton*btnA=new QPushButton (this);
    btnA->move(10,10);
    btnA->setFixedSize(200,200);

    QPushButton*btnB=new QPushButton (btnA);
    btnB->move(10,10);
    btnB->setFixedSize(100,100);

    QPushButton*btnC=new QPushButton (btnB);
    btnC->move(10,10);
    btnC->setFixedSize(50,50);
}

MainWindow::~MainWindow()
{
    delete ui;
}

  

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "testwidget.h"
#include "testdialog.h"
#include<QPushButton>
#include"subwindow.h"
#include<QtGlobal>
#include <QDebug>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    subwindow*sub=new subwindow(this);
    sub->show();

    int a =32;
    qintptr p=a;
    qDebug()<<p;
}

MainWindow::~MainWindow()
{
    delete ui;
}

  

posted @ 2025-08-15 16:18  华腾智算  阅读(4)  评论(0)    收藏  举报
https://damo.alibaba.com/ https://tianchi.aliyun.com/course?spm=5176.21206777.J_3941670930.5.87dc17c9BZNvLL