UpdateLayeredWindowIndirect failed for ptDst when move QComboBox between pages in QTabWidget
-
When QComboBox objects moves between pages in the QTabWidget, have "UpdateLayeredWindowIndirect failed for ptDst ..." and problems with the combobox displaying. It started from 6.7 version. Now it's in 6.7.2. It worked without problem in 6.6 version and earlier.
There is the code:mainwindow.hpp:
class MainWindow : public QMainWindow
{
Q_OBJECTpublic:
MainWindow(QWidget *parent = nullptr);
~MainWindow();private:
Ui::MainWindow *ui;QComboBox *m_comboBox_3;};
mainwindow.cpp:
ui->comboBox_1->addItem("1_1", 1);
ui->comboBox_1->addItem("2_1", 2);
ui->comboBox_1->addItem("3_1", 3);ui->comboBox_2->addItem("1_2", 1); ui->comboBox_2->addItem("2_2", 2); ui->comboBox_2->addItem("3_2", 3); m_comboBox_3 = new QComboBox(ui->tab_1); QHBoxLayout *layout_1 = (QHBoxLayout *)ui->tab_1->layout(); layout_1->insertWidget(0, m_comboBox_3); m_comboBox_3->addItem("1_3", 1); m_comboBox_3->addItem("2_3", 2); m_comboBox_3->addItem("3_3", 3); connect(ui->tabWidget, &QTabWidget::currentChanged, this, [this](int index) { if(0 == index) { QHBoxLayout *layout_2 = (QHBoxLayout *)ui->tab_2->layout(); if(ui->comboBox_1->parent() == ui->tab_2) layout_2->removeWidget(ui->comboBox_1); if(ui->comboBox_2->parent() == ui->tab_2) layout_2->removeWidget(ui->comboBox_2); if(m_comboBox_3->parent() == ui->tab_2) layout_2->removeWidget(m_comboBox_3); ui->comboBox_1->setParent(ui->tab_1); ui->comboBox_2->setParent(ui->tab_1); m_comboBox_3->setParent(ui->tab_1); QHBoxLayout *layout_1 = (QHBoxLayout *)ui->tab_1->layout(); layout_1->insertWidget(0, ui->comboBox_1); layout_1->insertWidget(1, ui->comboBox_2); layout_1->insertWidget(2, m_comboBox_3); } else { QHBoxLayout *layout_1 = (QHBoxLayout *)ui->tab_1->layout(); if(ui->comboBox_1->parent() == ui->tab_1) layout_1->removeWidget(ui->comboBox_1); if(ui->comboBox_2->parent() == ui->tab_1) layout_1->removeWidget(ui->comboBox_2); if(m_comboBox_3->parent() == ui->tab_1) layout_1->removeWidget(m_comboBox_3); ui->comboBox_1->setParent(ui->tab_2); ui->comboBox_2->setParent(ui->tab_2); m_comboBox_3->setParent(ui->tab_2); QHBoxLayout *layout_2 = (QHBoxLayout *)ui->tab_2->layout(); layout_2->insertWidget(0, m_comboBox_3); layout_2->insertWidget(1, ui->comboBox_2); layout_2->insertWidget(2, ui->comboBox_1); } });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>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QTabWidget" name="tabWidget">
<property name="geometry">
<rect>
<x>100</x>
<y>180</y>
<width>471</width>
<height>271</height>
</rect>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="tab_1">
<attribute name="title">
<string>Tab 1</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QComboBox" name="comboBox_1"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Tab 2</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QComboBox" name="comboBox_2"/>
</item>
</layout>
</widget>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui> -
Hi and welcome to devnet,
Not an answer to your question but why not take the combo boxes out of the tab widget since you are putting them back every time you switch ?
-
Hi! Thank you!
It's just a short example to show the problem. The Comboboxes in the real program work in the different programs regimes with the connections to some processes. User can switch regime (tab) but comboboxes have to work in the process and be accessible to customer. In other case I need to duplicate comboboxes to each regime of the program's work. -
Can you give more details about the design of your application ?
The combo box presence and handling seems to be pretty complicated.
-
In this part app has tabwidget with two regimes. For example, one regime is to work with the data through network and second regime is to work with the local data. Each page has its own set of the GUI elements (and comboboxes among them). They are grouped some way. Program is set to work regime according to what page is active. Combobox set some parameters of the objects that are working in current moment. And these parameters are the same for different objects. Therefore it was convenient to have one combobox on different pages of the tabwidget. User switches pages, but work with the combobox doesn't change.
-
Well, in that case, as I wrote before, your combo boxes should be independent of the stack if you really want to have only one set of them. If there are special rules that should be applied to them, you might want to consider putting them into their own widget so you can give them a proper interface to modify them rather than trying to put everything in a single widget.
-
O Olex has marked this topic as solved on