简体   繁体   English

QT 4.8中的几台显示器全屏应用

[英]Several monitors fullscreen application in QT 4.8

I use QT4.8 to create an application and I have two monitors with identical screen resolutions connected to the PC. 我使用QT4.8创建应用程序,并且将两台具有相同屏幕分辨率的显示器连接到PC。 How is it possible to make the application main window to be fullscreen on both monitors? 如何在两个监视器上使应用程序主窗口全屏显示?

Hope this code help you in some way: 希望这段代码以某种方式对您有所帮助:

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDesktopWidget> //INCLUDE THIS TO GET DESKTOP INFO

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
int x=0; //OUR X START POSITION
int y=0; //OUR Y START POSITION
QDesktopWidget *desktop = new QDesktopWidget();//OUR DESKTOP INSTANCE
/*HERE IM TAKING IN COUNT THAT WE HAVE SAME RESOLUTION ON ALL MONITOR,
SO NOW WE CAN GET WIDTH BY KNOWING THE QUANTITY OF MONITOR AND
MULTIPLYING MY THE FIRST MONITOR WIDTH*/
int width = desktop->screenCount()*desktop->screenGeometry(0).width();
int height = desktop->screenGeometry(0).height();//JUST GETTING MY FIRST   
//MONITOR HEIGHT WHICH IS THE SAME IN ALL MONITORS
this->setGeometry(x,y,width,height);//NOW I SET MY FINAL GEOMETRY TO         
//MY MAINWINDOW.


}

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

Maybe theres a faster and less code way but you can see how it works... Let me know if you need anything else. 也许有一种更快,更少的代码方式,但是您可以看到它的工作原理...让我知道您是否还有其他需要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM