[Qt-interest] How to adjust the size of window with different screens or resolution rate?
Ross Driedger
ross at earz.ca
Tue Nov 17 06:06:13 CET 2009
On Mon, 16 Nov 2009 23:33:49 -0500, <qt-interest-request at trolltech.com>
wrote:
> Message: 1
> Date: Tue, 17 Nov 2009 11:17:24 +0800 (CST)
> From: donglongchao <donglongchao at 163.com>
> Subject: [Qt-interest] How to adjust the size of window with different
> screens or resolution rate?
> To: "Qt Devel" <qt-interest at trolltech.com>
> Message-ID:
> <13212095.107601258427844482.JavaMail.coremail at bj163app27.163.com>
> Content-Type: text/plain; charset="gbk"
> Hi all,
> I am developing an GUI app with a 17" CRT screen whose resolution rate
> is 800*600 and it looks fine when I run it.But when I try to run it with
> a different screen that is a 22" LCD wide screen(resolution is
> 1024*800),the app looks very small and ugly and it can only cover 1/3 of
> the whole screen.So I want to know if there is any way to adjust the
> size of window with different screens?Any suggestion is appreciated.
> Thanks a lot in advance.
> Longchao
This is what I do in the context of multiheaded displays:
The QRect object will return the size of each monitor attached.
QDesktopWidget* dtw = QApplication::desktop();
int screens = dtw->numScreens();
QRect rect;
for(int nscreens = 0; nscreens < screens; ++nscreens)
{
QWidget* screen = dtw->screen(nscreens);
rect = screen -> geometry();
}
In another application, I needed my main window to fill the whole screen
minus any system elements like the menu bar, so this code is called in the
window's constructor:
QDesktopWidget qdw;
QRect rect = qdw.availableGeometry(this);
QStyle* style = static_cast<const
QApplication*>(QApplication::instance())->style();
setFixedSize(QSize(rect.width(), rect.height() -
style->pixelMetric(QStyle::PM_TitleBarHeight)));
move(0, 0);
Set your window size an placement as you wish.
Ross
--
"Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us."
Bill Waterson (Calvin & Hobbes)
Ross Driedger
ross_at_earz.ca
More information about the Qt-interest-old
mailing list