qt UI总结1

  1. 界面最大化
     MyWindow w;
	w.showMaximized();

其他方式:

添加头文件:<QScreen>,以下代码即可获得屏幕的高宽,若窗体显示不满屏,则将窗体的高宽设为屏幕的高宽即可。
    QScreen *screen = qApp->primaryScreen();
    int nWidth2 = screen->size().width();   //屏幕宽
    int nHeight2 = screen->size().height();

获取屏幕的最大最小宽度之后,可进行其他相关操作

2 关于类提升之后,控件如何调用该类

m_pShow = ui->widget;
    m_timer = new QTimer( this);
    m_timer->start( 200);
    originPoint.setX(xx);  originPoint.setY(yy);

    xx +=30;   yy +=25;
    QPointF temp( xx, yy);
    m_pShow->m_Point.append( temp);
    xx +=60;   yy +=65;
    QPointF temp1( xx, yy);
    m_pShow->m_Point.append( temp1);

    xx +=80;   yy +=95;
    QPointF temp2( xx, yy);
    m_pShow->m_Point.append( temp2);
    xx +=60;   yy +=15;
    QPointF temp3( xx, yy);
    m_pShow->m_Point.append( temp3);

    xx +=100;   yy +=25;
    QPointF temp4( xx, yy);
    m_pShow->m_Point.append( temp4);
    xx +=200;   yy +=115;
    QPointF temp5( xx, yy);
    m_pShow->m_Point.append( temp5);

    connect(m_timer,&QTimer::timeout, this,[=]() {
        xx +=30;   yy +=25;
        QPointF temp( xx, yy);
        m_pShow->m_Point.append( temp);


        if( xx>(this->width())-100){
            xx = 50;
        }
        if( yy>(this->height()-100)){
            yy = 50;
        }
        if( m_pShow->m_Point.length() > 5){
            update();
            // repaint();
        }
        if( m_pShow->m_Point.length() >300){
            m_timer->stop();
        }
    });

在qPainter实时绘制动态轨迹图 这里插入图片描述
qPainter实时绘制动态轨迹图
3 Qt状态栏(statusbar)
1 直接设置显示信息:
  ui->startBar->showMessage(tr(“显示内容”),0);
2 添加控件

    QLabel *Label = new QLabel;//定义label
    Label->setText("Qt状态栏(statusbar)的使用!");//label
    statusBar()->addWidget(Label);//将label加到状态栏上
//通过这种方式添加默认控件在最左侧显示
    QPushButton * button = new QPushButton();
    button->setObjectName("pb1");
    button->setText(tr("pb1"));
    ui->statusBar->addWidget(button);
    
    //通过下面方式添加默认在startBar的最右侧显示
    QLabel * displaymsg = new QLabel();
    displaymsg->setObjectName("LbDisplay");
    ui->statusBar->addPermanentWidget(displaymsg);

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值