From 8c0cdfdd4772e81164d838b9549e8c554ecf5966 Mon Sep 17 00:00:00 2001 From: Trond Kjernaasen Date: Tue, 3 Mar 2009 15:51:31 +0100 Subject: Work around a limitation in QFormLayout - 0 width content margins aren't really supported. Also set the default focus to be the preview widget itself. --- src/gui/dialogs/qprintpreviewdialog.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gui/dialogs/qprintpreviewdialog.cpp b/src/gui/dialogs/qprintpreviewdialog.cpp index 494c455..3580fdc 100644 --- a/src/gui/dialogs/qprintpreviewdialog.cpp +++ b/src/gui/dialogs/qprintpreviewdialog.cpp @@ -228,7 +228,6 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer) QObject::connect(preview, SIGNAL(previewChanged()), q, SLOT(_q_previewChanged())); setupActions(); - pageNumEdit = new LineEdit; pageNumEdit->setAlignment(Qt::AlignRight); pageNumEdit->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); @@ -265,13 +264,18 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer) toolbar->addAction(firstPageAction); toolbar->addAction(prevPageAction); - // this is to ensure the label text and the editor text - // are aligned in all styles + // this is to ensure the label text and the editor text are + // aligned in all styles - the extra QVBoxLayout is a workaround + // for bug in QFormLayout QWidget *pageEdit = new QWidget(toolbar); + QVBoxLayout *vboxLayout = new QVBoxLayout; + vboxLayout->setContentsMargins(0, 0, 0, 0); QFormLayout *formLayout = new QFormLayout; formLayout->setWidget(0, QFormLayout::LabelRole, pageNumEdit); formLayout->setWidget(0, QFormLayout::FieldRole, pageNumLabel); - pageEdit->setLayout(formLayout); + vboxLayout->addLayout(formLayout); + vboxLayout->setAlignment(Qt::AlignVCenter); + pageEdit->setLayout(vboxLayout); toolbar->addWidget(pageEdit); toolbar->addAction(nextPageAction); @@ -318,6 +322,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer) #endif ) pageSetupAction->setEnabled(false); + preview->setFocus(); } static inline void qt_setupActionIcon(QAction *action, const QLatin1String &name) -- cgit v0.12