#include <QtGui>
int main(int argc, char *argv[])
{
// My locale, in case it has a bearing
// default date format (d/mm/yy), right size for format
// wider date format, set before widget show(), right format and size
date2->setDisplayFormat("dd-MMM-yyyy");
// Another wider date format but set after widget show()
QFormLayout *form = new QFormLayout;
form->addRow("Default", date1);
form->addRow("Wider 1", date2);
form->addRow("Wider 2", date3);
widget.setLayout(form);
widget.show();
date3->setDisplayFormat("dd-MMM-yyyy"); // changes format but not widget size
// How do I force the geometry to be rethought after the parent widget is shown?
// The date3 widget sizeHint() is updated by the change
return app.exec();
}
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget widget;
// My locale, in case it has a bearing
QLocale::setDefault(QLocale(QLocale::English, QLocale::Australia));
// default date format (d/mm/yy), right size for format
QDateEdit *date1 = new QDateEdit(QDate::currentDate(), &widget);
// wider date format, set before widget show(), right format and size
QDateEdit *date2 = new QDateEdit(QDate::currentDate(), &widget);
date2->setDisplayFormat("dd-MMM-yyyy");
// Another wider date format but set after widget show()
QDateEdit *date3 = new QDateEdit(QDate::currentDate(), &widget);
QFormLayout *form = new QFormLayout;
form->addRow("Default", date1);
form->addRow("Wider 1", date2);
form->addRow("Wider 2", date3);
widget.setLayout(form);
widget.show();
date3->setDisplayFormat("dd-MMM-yyyy"); // changes format but not widget size
// How do I force the geometry to be rethought after the parent widget is shown?
// The date3 widget sizeHint() is updated by the change
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks