Child widgets inside a QDockWidget not updated when QDockWidget::setFloating(true)
-
Hello Qt guys,
I am facing a problem with QDockWidget children updates. Our code setup works fine with Qt5.6.2 and we recently upgraded to Qt5.12.10 and the problem comes up.
The problem is seen only if the QDockWidget is undocked(Floated). Everything works fine when docked again.
Some of the problems in child widgets updates like,- QCheckBox check state - not updated when we toggled.
- QScrollArea scrollbar - not updating when we scroll.
- QTreeView - not updating the expand/collapse the treeview items
Note: If we click outside the QDockWidget(ex: click on Mainwindow), then all the child widgets updated/refreshed to the correct state. So seems, update()/repaint()/... not happens with children interactions.
Our code setup:
- DockWidget creation with children
CustomDockWidget *dock = new CustomDockWidget("Test", m_pMainWindow); dock->setWidget(new CustomWidget(m_pMainWindow)); // CustomWidget children are not updated properly when QDockWidget is in floating state m_pMainWindow->addDockWidget(Qt::RightDockWidgetArea, dock); dock->show();
- DockWidget setup
CustomDockWidget::CustomDockWidget(const QString &title, QWidget *parent) : QDockWidget(title, parent) { setWindowFlags(windowFlags() | Qt::FramelessWindowHint); setAttribute(Qt::WA_TranslucentBackground, true); // suspecting the problem with this attribute setAttribute(Qt::WA_NoSystemBackground, false); setFloating(true); setFeatures(QDockWidget::DockWidgetFloatable); setTitleBarWidget(new CustomTitleBar(this)); }
If we comment, "setAttribute(Qt::WA_TranslucentBackground, true);" everything works fine in both dock & undocked state. But we should need this, to show the QDockWidget in a transparent state in some scenarios.
So, anyone please help me out to find the root cause of this problem of updating Qt5.6.2 to Qt5.12.10 with Qt::WA_TranslucentBackground attribute setup.
Thanks.
-
Hi and welcome to devnet,
Can you provide a minimal compilable example that triggers this change of behaviour ?
-
Are the widgets in the dock computational expensive?
I had similar problems with 3D-plots in docks. The problem in my case could be traced to a timing issue. When the widgets took some time to render then they would not correctly update.
Solution was to add a QTimer::singleShot() that triggers an update after docking/undocking with some delay. -
@gde23
Hi,
The widgets do not have any expensive computations and also do not have any render-related widgets. In my case, a simple scroll area with scrollable contents is not updating in the floatable dock widget. In my case, the problem is not during the dock or un dock time. Once the widget is un docked, then if we do any interactions on ui(ex: scroll the content in scroll area) then its not updating the scroll bars position, contents. -
I insist, a minimal compilable example would allow us to test your issue.
-
@Ashokraj-Ramasamy said in Child widgets inside a QDockWidget not updated when QDockWidget::setFloating(true):
Check whether the CustomWidget correctly uses a layout also.