Unsolved Widget jumps/flickers when hide another widget
-
Hi,
I have unpleasant behavior for my application which i do not know how to eliminate. My application is huge and has a lot of UI components. I prepared sandbox where it also possible to reproduce. The test app more less has the same widget structure as the main app. The main problem is, when "main area" is hiding the "Hide" button jumps for a moment below and back to correct place. The fastest way to reproduce is quick clicking on the button)Qt5.12.5, Win 10
mainwindow.h#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } QT_END_NAMESPACE class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = nullptr); ~MainWindow(); private: Ui::MainWindow *ui; }; #endif // MAINWINDOW_H
mainwindow.cpp
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QPushButton> #include <QListView> #include <QDebug> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); connect(ui->pushButton, &QPushButton::clicked, [this](bool checked) { ui->listWidget->setHidden(checked); }); } MainWindow::~MainWindow() { delete ui; }
mainwindow.ui
<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>MainWindow</class> <widget class="QMainWindow" name="MainWindow"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>1000</width> <height>751</height> </rect> </property> <property name="sizePolicy"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="minimumSize"> <size> <width>500</width> <height>500</height> </size> </property> <property name="maximumSize"> <size> <width>1000</width> <height>800</height> </size> </property> <property name="windowTitle"> <string>MainWindow</string> </property> <widget class="QWidget" name="centralwidget"> <layout class="QVBoxLayout" name="verticalLayout"> <item> <widget class="QWidget" name="keyboard_search" native="true"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="minimumSize"> <size> <width>0</width> <height>0</height> </size> </property> <property name="styleSheet"> <string notr="true">border-radius: 2px; border: 1px solid red;</string> </property> <layout class="QHBoxLayout" name="horizontalLayout"> <property name="spacing"> <number>0</number> </property> <property name="leftMargin"> <number>0</number> </property> <property name="topMargin"> <number>0</number> </property> <property name="rightMargin"> <number>0</number> </property> <property name="bottomMargin"> <number>0</number> </property> <item> <spacer name="horizontalSpacer"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>40</width> <height>20</height> </size> </property> </spacer> </item> <item> <widget class="QWidget" name="keyboard" native="true"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="minimumSize"> <size> <width>700</width> <height>0</height> </size> </property> <property name="maximumSize"> <size> <width>700</width> <height>16777215</height> </size> </property> <layout class="QVBoxLayout" name="verticalLayout_2"> <property name="leftMargin"> <number>0</number> </property> <property name="topMargin"> <number>0</number> </property> <property name="rightMargin"> <number>0</number> </property> <property name="bottomMargin"> <number>0</number> </property> <item> <widget class="QPushButton" name="pushButton"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="minimumSize"> <size> <width>0</width> <height>70</height> </size> </property> <property name="maximumSize"> <size> <width>16777215</width> <height>70</height> </size> </property> <property name="text"> <string>Hide</string> </property> <property name="checkable"> <bool>true</bool> </property> </widget> </item> <item> <widget class="QListWidget" name="listWidget"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> </widget> </item> </layout> </widget> </item> <item> <spacer name="horizontalSpacer_2"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>40</width> <height>20</height> </size> </property> </spacer> </item> </layout> </widget> </item> <item> <widget class="QWidget" name="widget_2" native="true"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="styleSheet"> <string notr="true">border-radius: 2px; border: 1px solid blue;</string> </property> <layout class="QVBoxLayout" name="verticalLayout_3"> <property name="spacing"> <number>0</number> </property> <property name="leftMargin"> <number>0</number> </property> <property name="topMargin"> <number>0</number> </property> <property name="rightMargin"> <number>0</number> </property> <property name="bottomMargin"> <number>0</number> </property> <item> <widget class="QWidget" name="mainArea" native="true"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> </widget> </item> </layout> </widget> </item> </layout> </widget> </widget> <resources/> <connections/> </ui>
I am very appreciate for the help. -
Works fine for me with Qt5.15 on Windows and Linux.
-
I have also checked on different hardware, OS and qt versions. this behavior also present.
-
Hi,
@Andeksan said in Widget jumps/flickers when hide another widget:
I have also checked on different hardware, OS and qt versions. this behavior also present.
Which Qt versions ?
Which OSs ?Did you stay in the 5.12 series or did you try more recent as well ?
Did you check your graphics card drivers ? -
Qt versions : 5.3.2, 5.4.1, 5.7.0, 5.12.5.
OSs: win 10, KDE(20.04).
Hardware: Latitude 7400, ROG GL552.For Latitude 7400 video driver is up to date. For ROG is old.
-
Why do you expect that it works with an older version (except it would be a regression). Update to 5.15 and check again.
-
@Christian-Ehrlicher does not make sense to try because project uses Qt5.12.5.
-
Then you have to live with it. Neither 5.12.5 will be fixed nor looks it like a problem in your code.
-
Hi
I tried with Qt 5.9.1 in linux and i cant get it to do it.
-
@mrjj, @Christian-Ehrlicher thanks for checking. i see that is not reproducible on your side.
I did more checks: with qt 5.15.2 and 6.0.1 and on my side this bug is still presented. Also i tried on VM with KDE qt 5.12.8 only there it works normally. -
So even with 5.15.2 you see this on your systems?
Also, the Latitude 7400 is not very old, is it ?
-
@mrjj yes i see this effect on 5.15.2 and 6.0.1. I would say Latitude 7400 is fresh.
-
Do they have anything in common gfx wise ?
Like both using intel driver or similar ?It cant really be the app as its as basic as possible so i think it some sort
of gfx glitch but I also tried on old laptop that has 3d issues but
not even there i could get it to do it.Looking at the video , it seems it has an extra redraw while the layout adjusts.
Im not really sure how we can work around it as not sure why we can see it in the video.
-
@mrjj yes both laptops use Intel UHD Graphics. it can be cause of this behavior. Before this post i tried to find similar discussions in the internet and there are of few of them. Seems to me this issue is kind of single cases and hardware/driver depended. I think, if i have spare time i will investigate it deeper.
-
well, it could be something like that.
It might not happen that often either.
At least, I could not get the demo code to show even trying around
different hardware.