• 9425阅读
  • 9回复

如何获取当前屏幕分辨率宽度? [复制链接]

上一主题 下一主题
离线tsuibin
 

只看楼主 倒序阅读 楼主  发表于: 2009-11-06
我在程序中 如何方便的获取当前显示的分辨率?
有没有int window.width() 之类的方法?
离线jorneyr

只看该作者 1楼 发表于: 2009-11-06
QDesktopWidget * QApplication::desktop ()   [static]

const QRect QDesktopWidget::screenGeometry ( int screen = -1 ) const
Returns the geometry of the screen with index screen. The default screen is used if screen is -1.
See also screenNumber().

int QRect::width () const
int QRect::height () const
离线hiti_tony
只看该作者 2楼 发表于: 2009-11-06
学习ing
离线tsuibin

只看该作者 3楼 发表于: 2009-11-11
error: cannot call member function ‘const QRect QDesktopWidget::screenGeometry(int) const’ without object
离线dbzhang800

只看该作者 4楼 发表于: 2009-11-11
引用第3楼tsuibin于2009-11-11 16:53发表的  :
error: cannot call member function ‘const QRect QDesktopWidget::screenGeometry(int) const’ without object


翻译成中文就是你要的答案了。

题外,有时间多看看C++吧
离线tsuibin

只看该作者 5楼 发表于: 2009-11-11
class WebCross : public QWidget
QWidget有没有获取屏幕分辨率的方法
离线dbzhang800

只看该作者 6楼 发表于: 2009-11-11
error: cannot call member function ‘const QRect QDesktopWidget::screenGeometry(int) const’ without object

已经说的很明确了,要访member function QDesktopWidget::screenGemetry,必须先创建类的 object
离线tsuibin

只看该作者 7楼 发表于: 2009-11-11
thanks
离线sufangchao
只看该作者 8楼 发表于: 2009-11-12
QApplication::desktop()->availableGeometry
    Returns the available geometry of the screen with index screen. What is available will be subrect of screenGeometry() based on what the platform decides is available (for example excludes the dock and menu bar on Mac OS X, or the task bar on Windows).
QApplication::desktop()->screenGeometry
    Returns the geometry of the screen with index screen.
离线cspp

只看该作者 9楼 发表于: 2009-11-12
回答的真够手把手了
快速回复
限100 字节
 
上一个 下一个