QDialog margin and spacing
I'm using solaris 5.8, Qt 4.2.2 and gcc 3.3 and have been trying to create a dialog with no margin or spacing for its child widgets. Unfortunately, things aren't going too well. It turns out that i only get the desired effect if i use a QWidget or QMainWindow instead of a QDialog. Could this be a bug in Qt?
Below is some code that produces two windows, one being a QDialog and the other a QWidget. The QDialog behaves incorrectly, insisting on drawing a margin and spacing for the child widgets, while the QWidget has the desired behavior.
Code:
#include <QApplication>
#include <QDialog>
#include <QVBoxLayout>
#include <QPushButton>
int main(int argc, char** argv)
{
//////////////////////////////////////////////////////////////////////
// create a dialog with two buttons
diag.setWindowFlags(Qt::Widget);
diag.setWindowTitle("dialog");
diag.setLayout(layout);
button1->setSizePolicy(policy);
layout->addWidget(button1);
button2->setSizePolicy(policy);
layout->addWidget(button2);
layout->setMargin(0);
layout->setSpacing(0);
diag.show();
//////////////////////////////////////////////////////////////////////
// create a widget with two buttons
widg.setWindowTitle("widget");
widg.setLayout(layout);
button1->setSizePolicy(policy);
layout->addWidget(button1);
button2->setSizePolicy(policy);
layout->addWidget(button2);
layout->setMargin(0);
layout->setSpacing(0);
widg.show();
return app.exec();
}
Please, can any of you confirm the incorrect behavior? Or maybe i'm alone out here on Solaris island? ;)
Thanks in advance!
Re: QDialog margin and spacing
Could you provide a screenshot? Which style are you using? Does it happen with other styles, for example:
Quote:
./app -style plastique
1 Attachment(s)
Re: QDialog margin and spacing
Attachment 1684
As you can see in the attached screenshot, the cde, motif and windows styles force the dialog to have a margin and spacing. It's most apparent in cde and motif. Cleanlooks, plastique and WindowsXp do not produce a noticable margin and spacing.
Re: QDialog margin and spacing
Looks weird, indeed. I'd suggest opening a new task at the task-tracker.
Re: QDialog margin and spacing...Solved!
Apparently, the discrepancy is due to the autodefault property:
http://doc.trolltech.com/4.2/qpushbu...toDefault-prop
And hats off to trolltech for their speedy reply to my query. :)