栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

QT5关于屏幕的设置

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

QT5关于屏幕的设置

获取屏幕分辨率大小

以往获取屏幕分辨率的方法是用,但是QT5之后淘汰了,需要用QGuiApplication这个类来操作了

QDesktopWidget* desktopWidget = QApplication::desktop();//获取可用桌面大小
QRect deskRect = desktopWidget->availableGeometry();//获取设备屏幕大小
QRect screenRect = desktopWidget->screenGeometry();

新的方法如下

#include 
#include
    QScreen *screen=QGuiApplication::primaryScreen ();//获取主屏幕
    QRect mm=screen->availableGeometry() ;//返回屏幕可用几何图形大小
    int screen_width = mm.width();//屏幕宽度
    int screen_height = mm.height();//屏幕高度
    QList list_screen = QGuiApplication::screens();// 获取多显示器,通过list存储当前主机所有显示器
    QRect rect = list_screen.at(0)->geometry();//获取第一个屏幕
	int desktop_width = rect.width();//屏幕宽度
	int desktop_height = rect.height();//屏幕高度
	QPoint f = QPoint(25, 25);
    QScreen * scree = QGuiApplication::screenAt(f);//返回点所在的屏幕
QWidget窗口的部分显示有关的功能

QT中,GUI最终都继承自QWidget,所的调用update()都是基类QWidget的update()。

基础函数:
paintEvent(QPaintEvent*)函数是QWidget类中的虚函数,用于ui的绘制,会在多种情况下被其他函数自动调用,比如update()时

  • repaint(),被调用之后,立即执行重绘,因此repaint是最快的

  • update()跟repaint()比较,update则更加有优越性

    void update(const QRect&);
    void update(const QRegion&);

    void repaint(int x, int y, int w, int h);
    void repaint(const QRect &);
    void repaint(const QRegion &);
    void showMinimized();//缩放最小
    void showMaximized();//缩放最大
    void showFullScreen();//全屏显示
    void showNormal();//正常显示

    void show();//显示
    void hide();//隐藏
    
    bool close();//关闭
    void raise();//显示窗体在最前面
    void lower();//显示窗体在最后面
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/992460.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号