我在 DirectFB 1.7.4 之上运行了 Qt 5.3(以及 qdirectfbintegration 的一个小补丁,因为未实现 platformNativeInterface)。
我提出了 3840x2160 分辨率,然后使用下面的代码更改为 1920x1080 分辨率。分辨率发生变化,我可以确认查看 fbset 输出。我看到的问题是,将分辨率更改为 1920x1080 Qt 后仍将其报告为 3840x2160。
有谁知道如何强制 Qt 重新检查/更新它报告的分辨率?或者 directfb 插件中可能缺少什么来通知 Qt 引擎盖下发生了一些变化?
谢谢。
IDirectFB * dfb = (IDirectFB*)m_app->platformNativeInterface();
if(dfb){
std::cerr << "######## New resolution is " << width << "x" << height << std::endl;
IDirectFBDisplayLayer *layer;
DFBDisplayLayerConfig config;
std::cerr << "######## Getting primary IDirectFBDisplayLayer" << std::endl;
/* Get an interface to the primary layer. */
dfb->GetDisplayLayer(dfb, DLID_PRIMARY, &layer);
if(layer){
DFBResult dres;
std::cerr << "######## Got the primary display layer, setting admin" << std::endl;
// This level allows window stack mode switches
dres = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
if(dres != DFB_OK){
std::cerr << "######## Error: " << DirectFBErrorString(dres) << std::endl;
}
std::cerr << "######## Getting layer configuration" << std::endl;
// Get layer configuration
dres = layer->GetConfiguration(layer, &config);
if(dres != DFB_OK){
std::cerr << "######## Error: " << DirectFBErrorString(dres) << std::endl;
}
// Set the new resolution
std::cerr << "######## Setting layer resolution" << std::endl;
config.width = width;
config.height = height;
dres = layer->SetConfiguration(layer, &config);
if(dres != DFB_OK){
std::cerr << "######## Error: " << DirectFBErrorString(dres) << std::endl;
}
}
// Print out resolution from Qt
QRect res = QApplication::desktop()->screenGeometry();
std::cerr << "######## QApplication resolution is now " << res.width() << "x" << res.height() << std::endl;
我从控制台看到的输出是:
######## New resolution is 1920x1080
######## Getting primary IDirectFBDisplayLayer
######## Got the primary display layer, setting admin
######## Getting layer configuration
######## Setting layer resolution
(*) FBDev/Mode: Setting 1920x1080 ARGB
(*) FBDev/Mode: Switched to 1920x1080 (virtual 1920x2160) at 32 bit (ARGB), pitch 7680
######## QApplication resolution is now 3840x2160
root@output:~# fbset
mode "1920x1080-24"
# D: 74.250 MHz, H: 27.000 kHz, V: 24.000 Hz
geometry 1920 1080 1920 2160 32
timings 13468 148 638 36 4 44 5
accel false
rgba 8/16,8/8,8/0,8/24
endmode