[Interest] QWiget in X.org fails to get full screen without window manager in Qt 5 but works in Qt 4

Francisco Ares frares at gmail.com
Fri Feb 16 14:31:57 CET 2018


Hi,

A QWidget based program built with Qt 5 (5.7.1 to be more exact) and built
with Qt 4 (4.8.7) behaves differently.

I have a Linux box just with X.org, no window manager.  There is an auto
login user that starts X with this ~/.xinitrc :

xloadimage -onroot -quiet -fullscreen /home/vision/background.jpeg
setterm -blank 0 -powersave off -powerdown 0
xset s off
xset -dpms
xrdb ~/.Xresources
exec /home/vision/bin/test5
# exec /home/vision/bin/test4


The latest lines are used to select the "test" program (main.cpp and
test.pro below), built against Qt5 ("test5") or Qt4 ("test4"):

// ------- main.cpp

#include <QApplication>
#include <QDesktopWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QSpacerItem>
#include <QWidget>
#include <QString>
#include <QPushButton>

       QHBoxLayout * horizontalLayout;
       QVBoxLayout * verticalLayout;

int main(int argc, char *argv[])
{
       QApplication a(argc, argv);
       QWidget *widget = new QWidget();
       widget->resize(800, 600);

       int X = qApp->desktop()->screenGeometry().width();
       int Y = qApp->desktop()->screenGeometry().height();
       QString resolution = QString("Screen Geometry = %1 X
%2").arg(X).arg(Y);

       horizontalLayout = new QHBoxLayout();
       horizontalLayout->setSpacing(5);
       horizontalLayout->setContentsMargins(11, 11, 11, 11);
       horizontalLayout->setSizeConstraint(QLayout::SetMinimumSize);
       horizontalLayout->setContentsMargins(5, 5, 5, 5);

       verticalLayout = new QVBoxLayout();
       verticalLayout->setSpacing(5);
       verticalLayout->setContentsMargins(11, 11, 11, 11);
       verticalLayout->setSizeConstraint(QLayout::SetMinimumSize);
       horizontalLayout->setContentsMargins(5, 5, 5, 5);

       QSpacerItem * verticalSpacer_01 = new QSpacerItem(20, 10,
QSizePolicy::Minimum, QSizePolicy::Expanding);
       QPushButton * button_01 = new QPushButton(resolution, widget);
       QSpacerItem * verticalSpacer_02 = new QSpacerItem(20, 10,
QSizePolicy::Minimum, QSizePolicy::Expanding);

       QSpacerItem * horizontalSpacer_01 = new QSpacerItem(10, 20,
QSizePolicy::Expanding, QSizePolicy::Minimum);
       QSpacerItem * horizontalSpacer_02 = new QSpacerItem(10, 20,
QSizePolicy::Expanding, QSizePolicy::Minimum);

       verticalLayout->addItem(verticalSpacer_01);
       verticalLayout->addWidget(button_01);
       verticalLayout->addItem(verticalSpacer_02);

       horizontalLayout->addItem(horizontalSpacer_01);
       horizontalLayout->addItem(verticalLayout);
       horizontalLayout->addItem(horizontalSpacer_02);

       QObject::connect(button_01, SIGNAL(pressed()), widget,
SLOT(close()));

       widget->setLayout(horizontalLayout);

       widget->showFullScreen();
       widget->setWindowState(Qt::WindowFullScreen);

       return a.exec();
}

// ------- end of main.cpp


# -------- test.pro - it changes the TARGET according to which Qt major
version used;

QT       += core
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = test4
greaterThan(QT_MAJOR_VERSION, 4): TARGET = test5

TEMPLATE = app
DEPENDPATH += .
INCLUDEPATH += .

SOURCES += main.cpp

# -------- end of test.pro


Although using any of the window managers I've tested results the same
(very little visual differences), the Qt-5 version is unable to go full
screen when not using a window manager, although it is able to read the
screen resolution.

I've tried to mangle a full screen, but the widget is unable to show
anything on the region that it didn't reach at start.  I mean, if the
program starts as a partial window and I set it up to resize to full screen
resolution, the new area is not used to paint anything.

Is it a bug, or will I **have to** use a window manager?

In fact, the application I run in this box is the only one that will run at
all and the only one available, so I thought I would never need a window
manager.

Thanks a lot.
Francisco
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180216/3253e3a7/attachment.html>


More information about the Interest mailing list