2 Attachment(s)
Are the QTabWidget and QTableView drawn based on the top-level window?
Here is my question:
1. A transparent window(with Qt::Window Flag) has 2 sub-child-widget layouted by QVBoxLayout, and the buttom one has another sub-child-widget QTabWidget which then I put some QTableViews on. ----the structre
2. Back to the top-level window, if I invoke blew:
toplevelWindow->setAutoFillBackground(false); it'll show the window like:
2.jpg(the first image) well transparency, but the Table View was not correct
3. toplevelWindow->setAutoFillBackground(true); it'll show the windowas:
1.jpg(the second image) the Background was painted black by system
I just want the top-level window to be transparent but not child widget...
PlateForm: Windows +qt 4.5.2
Re: Are the QTabWidget and QTableView drawn based on the top-level window?
Is there anyone who can help me with this problem...thx...
Re: Are the QTabWidget and QTableView drawn based on the top-level window?
Could you maybe explain again in other words what you mean? I don't see a question in your question :)
Re: Are the QTabWidget and QTableView drawn based on the top-level window?
Quote:
Originally Posted by
wysota
Could you maybe explain again in other words what you mean? I don't see a question in your question :)
ok, if I set the attribute of the top level widget with Qt::WA_TranslucentBackground but not set the autoFillBackground, then the child widget (like QTabWidget and QTableWidget) will not show as I want;
And if I set them both (WA_TranslucentBackground and autoFillBackground), the child widget act as what I expect but the top level widget was not transparent...
Do you know what I mean now? Thank you for your reply....
Re: Are the QTabWidget and QTableView drawn based on the top-level window?
So you want a translucent parent with an opaque child, correct? I don't see why it shouldn't work, so we can try pinpointing the problem. Could you prepare a minimal compilable example reproducing the problem?
Re: Are the QTabWidget and QTableView drawn based on the top-level window?
Did you see the jpgs that I uploaded before?
I've already test the code for many times and the different between them is that if I set the transparency attribute of the top-level window. If it does then part of the child widgets(e.g through the QTabWidget's tab part we can see the desktop ) will show unexpected results.
Hers is my code:
Code:
:QWidget(parent, Qt
::FramelessWindowHint | Qt
::Dialog) {
//this->setAutoFillBackground(true); //if it is set the top-level window was not transparent
//if not, the child widget was not show correctly
this->setAttribute(Qt::WA_TranslucentBackground);
this->move(50, 50);
this->resize(420, 430);
this->Initialize();
}
Code:
void DDialog::Initialize()
{
this->setLayout(layout);
layout->setMargin(0);
layout->setSpacing(0);
//TitleBar ZONE
this->m_titleBar = new DTitleBar(this);
layout->addWidget(m_titleBar);
this
->m_mainWidget
= new QWidget();
layout->addWidget(m_mainWidget);
m_mainWidget->setAutoFillBackground(true);
layout->addWidget(statusBar);
statusBar->setAutoFillBackground(true);
this->m_mainWidget->setLayout(centerLayout);
//TabWidget ZONE
this->m_tabWidget->setAttribute(Qt::WA_OpaquePaintEvent);
centerLayout->addWidget(this->m_tabWidget);
centerLayout->setMargin(10);
this->m_tabWidget->setAutoFillBackground(true);
m_tabWidget
->setGeometry
(QRect(20,
20,
381,
361));
this
->m_tabWidget
->setTabPosition
(QTabWidget::North);
this
->m_tabWidget
->setTabShape
(QTabWidget::Rounded);
this->m_tabWidget->setElideMode(Qt::ElideMiddle);
//TableView ZONE
this->m_bmpTableHView->setAutoFillBackground(true);
this->m_bmpTableIView->setAutoFillBackground(true);
this
->m_bmpTableHView
->setGeometry
(QRect(-10,
-10,
391,
351));
this
->m_bmpTableHView
->setFrameShadow
(QFrame::Sunken);
this->m_tabWidget->addTab(this->m_bmpTableHView, "BitMapHead");
this->m_tabWidget->addTab(this->m_bmpTableIView, "BitMapInfoHead");
//QStandardItemModel ZONE
this->m_tableHModel->setHeaderData(0, Qt::Horizontal, tr("Name"));
this->m_tableHModel->setHeaderData(1, Qt::Horizontal, tr("Bytes"));
this->m_tableHModel->setHeaderData(2, Qt::Horizontal, tr("Value"));
this->m_bmpTableHView->setModel(this->m_tableHModel);
this->m_tableIModel->setHeaderData(0, Qt::Horizontal, tr("Name"));
this->m_tableIModel->setHeaderData(1, Qt::Horizontal, tr("Bytes"));
this->m_tableIModel->setHeaderData(2, Qt::Horizontal, tr("Value"));
this->m_bmpTableIView->setModel(this->m_tableIModel);
//BUTTON ZONE
centerLayout->addLayout(buttomLayout);
this
->m_OK
->setGeometry
(QRect(230,
390,
77,
25));
this->m_OK->setText(tr("OK"));
buttomLayout->addWidget(m_OK, 0, Qt::AlignRight);
this
->m_Cancel
->setGeometry
(QRect(310,
390,
77,
25));
buttomLayout->addWidget(m_Cancel);
this->m_Cancel->setText(tr("Cancel"));
}
Re: Are the QTabWidget and QTableView drawn based on the top-level window?
Please provide something compilable, I'd like to play a bit with the code.
1 Attachment(s)
Re: Are the QTabWidget and QTableView drawn based on the top-level window?
This is the project(compressed by winrar, I added ".zip" at the end)...
Thx
1 Attachment(s)
Re: Are the QTabWidget and QTableView drawn based on the top-level window?
Apart from weird mouse handling it works quite correct for me on Linux.
Here is a shot:
Re: Are the QTabWidget and QTableView drawn based on the top-level window?
Look... apparently my interpretation of a "minimal compilable example reproducing the problem" and yours differ greatly. I'm not going to read through serveral hundred lines of code with texts I don't understand to find a solution to a problem I don't see. Please provide a minimal compilable example clearly reproducing the problem, at most 100 lines of code in a total of one class plus the main function. Currently you have provided a bunch of classes that intend to do something but it is far from being clear what they do, how they are activated, etc.