- 界面最大化
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实时绘制动态轨迹图
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);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。