Ashish
11th July 2019, 16:33
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:
#include <QApplication>
#include <QWidget>
#include <QColorDialog>
#include <QHBoxLayout>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *w = new QWidget(nullptr);
QColorDialog *cDialog = new QColorDialog(w);
cDialog->setWindowFlags(Qt::Widget);
cDialog->setOptions(QColorDialog::DontUseNativeDialog
| QColorDialog::NoButtons);
QHBoxLayout *hl = new QHBoxLayout(w);
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
13186
Can anyone help me fix the issue?
Thanks,
Ashish
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:
#include <QApplication>
#include <QWidget>
#include <QColorDialog>
#include <QHBoxLayout>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *w = new QWidget(nullptr);
QColorDialog *cDialog = new QColorDialog(w);
cDialog->setWindowFlags(Qt::Widget);
cDialog->setOptions(QColorDialog::DontUseNativeDialog
| QColorDialog::NoButtons);
QHBoxLayout *hl = new QHBoxLayout(w);
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
13186
Can anyone help me fix the issue?
Thanks,
Ashish