1 Attachment(s)
correctly embed QColorDialog in QWidget
Hi,
I am trying to embed QColorDialog in a QWidget. After I add the QColorDialog, it shows up correctly, but the layouting doesn't work correctly.
When I stretch the QWidget by dragging from the bottom right corner, the QColorDialog doesn't occupy the entire resized QWidget. It only stays in the center.
The minimal code to reproduce this is as follows:
Code:
#include <QApplication>
#include <QWidget>
#include <QColorDialog>
#include <QHBoxLayout>
int main(int argc, char *argv[])
{
cDialog->setWindowFlags(Qt::Widget);
hl->addWidget(cDialog);
w->setLayout(hl);
w->show();
return a.exec();
}
If I replace the QColorDialog with QFontDialog, this works correctly. Please see the attached screenshot that shows the issue
Attachment 13186
Can anyone help me fix the issue?
Thanks,
Ashish
Re: correctly embed QColorDialog in QWidget
What is the resize behavior of the dialog content when you use the dialog directly?
Maybe its layout is such that the content stays centered.
Checking the code it has a fixed size.
Cheers,
_
Re: correctly embed QColorDialog in QWidget
Indeed, it has a fixed size constraint.
Any hints on how to achieve resizing without having to rewrite the entire class again?
Thanks,
Ashish
Re: correctly embed QColorDialog in QWidget
I would try unsetting the size constraint of the dialog's layout(), i.e. either setting it to QLayout::SetNoConstraint or QLayout::SetDefaultConstraint
Cheers,
_
1 Attachment(s)
Re: correctly embed QColorDialog in QWidget
Unfortunately, both SetNoConstraint and SetDefaultConstraint do not work. Please see the attached screenshot. There is a spacer in the original dialog that creates the problem.
Attachment 13190
Thanks,
Ashish