This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Centering a KDE Window

Tags: None
(comma "," separated)
User avatar
lin-unix
Registered Member
Posts
34
Karma
0
OS

Centering a KDE Window

Fri Jan 07, 2011 9:49 pm
Does anyone know how to center a KDE window either in the constructor or in before widget->show() is run in main()?

I tried this,
Code: Select all
mainWindow->move(KApplication::desktop()->screen()->rect().center() - mainWindow->rect().center());


But it gives me an error at "KApplication::desktop()",
<snip>/main.cpp:44:45: error: invalid use of incomplete type ‘struct QDesktopWidget’
/usr/include/QtGui/qapplication.h:73:7: error: forward declaration of ‘struct QDesktopWidget’
pinotree
KDE Developer
Posts
222
Karma
7
OS

Re: Centering a KDE Window  Topic is solved

Fri Jan 07, 2011 10:07 pm
lin-unix wrote:
<snip>/main.cpp:44:45: error: invalid use of incomplete type ‘struct QDesktopWidget’
/usr/include/QtGui/qapplication.h:73:7: error: forward declaration of ‘struct QDesktopWidget’

This is telling you it does not know about QDesktopWidget. Easy to solve, just:
Code: Select all
#include <QDesktopWidget>


Pino Toscano
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: Centering a KDE Window

Fri Jan 07, 2011 10:09 pm
You need to #include <QDesktopWidget> for the given code to compile. You may also need QRect.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], markhm, rblackwell, sethaaaa, Sogou [Bot], Yahoo [Bot]