From 7195badbe2ff943d730f7d79ab183acec8ce26c3 Mon Sep 17 00:00:00 2001 From: Arno Date: Wed, 17 Aug 2011 21:46:39 +0200 Subject: Center Dialogs on screen Since I'm now using a tiling window manager dialogs have to center themselves on the screen. Otherwise they end up at QPoint(0,0). Not very nice. Subclassed QDialog to SmDialog and converted all dialogs. --- helper.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'helper.cpp') diff --git a/helper.cpp b/helper.cpp index 247baca..80a8bc2 100644 --- a/helper.cpp +++ b/helper.cpp @@ -17,6 +17,10 @@ #include #include #include +#include +#include +#include +#include #include @@ -201,5 +205,11 @@ namespace Helper { bool FileInfoListContains::operator ()(const QFileInfo &info, const QString &file) const { return info.fileName() == file; } + + void centerWidget(QWidget *widget){ + QRect widgetRect = widget->rect(); + widgetRect.moveCenter(qApp->desktop()->screenGeometry().center()); + widget->move(widgetRect.topLeft()); + } } -- cgit v1.2.3-70-g09d2