Results 1 to 5 of 5

Thread: QDesktopWidget initialization

  1. #1
    Join Date
    Apr 2008
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default QDesktopWidget initialization

    I am trying to write an application that will use multiple screens, if available. I know how to open windows on target screens, but QApplication::desktop()->numScreens() returns 1, even on a 4 screen setup. In examining the Qt (3 and 4) source code, I see that the private attribute QDesktopWidget::d is only initialized (QDesktopPrivate::init()) in resizeEvent(). I have tried sending a resize event, but no joy.

    For now, I will use ScreenCount(QPaintDevice::x11AppDisplay()) to get the number of screens, but I am curious as to how to get the QDesktopWidget::init() method called.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDesktopWidget initialization

    Am not sure about the number of screens,
    but u can try this -
    Call a QTimer::singlShot(0,this,initialize()); from the constructor.

    In the initialize function try to get the number of screens
    Qt Code:
    1. MyWindow::initialize()
    2. {
    3. m_no_of_screens = qApp->desktop()->numScreens();
    4. }
    To copy to clipboard, switch view to plain text mode 

    see if the value is correct this time.

  3. #3
    Join Date
    Apr 2008
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QDesktopWidget initialization

    Thanks for the suggestion, but still no luck.

  4. #4
    Join Date
    Apr 2008
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QDesktopWidget initialization

    Solved. I am using Qt3, and had xinerama support turned on. It evidently conflicted with nvidia driver in "non-twinview" mode. Partial olution is to turn off xinerama. Also had to patch qdesktopwidget_x11.cpp. Looks like they (Trolltech) fixed qdesktopwidget_x11.cpp in Qt4.

  5. #5
    Join Date
    May 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDesktopWidget initialization

    Quote Originally Posted by drweilert View Post
    I am trying to write an application that will use multiple screens, if available. I know how to open windows on target screens, but QApplication::desktop()->numScreens() returns 1, even on a 4 screen setup. In examining the Qt (3 and 4) source code, I see that the private attribute QDesktopWidget::d is only initialized (QDesktopPrivate::init()) in resizeEvent(). I have tried sending a resize event, but no joy.

    For now, I will use ScreenCount(QPaintDevice::x11AppDisplay()) to get the number of screens, but I am curious as to how to get the QDesktopWidget::init() method called.
    Hi Dear
    Would you tell me how can i affecte a widget to a spesific screen please ?

Similar Threads

  1. QWT application initialization error
    By Urban in forum Qwt
    Replies: 3
    Last Post: 17th September 2008, 10:17
  2. static member initialization
    By high_flyer in forum General Programming
    Replies: 2
    Last Post: 17th September 2007, 21:22
  3. QDesktopWidget Screenshot && Mouse grab
    By patrik08 in forum Qt Programming
    Replies: 3
    Last Post: 29th March 2007, 10:51
  4. Initialization code
    By Doug Broadwell in forum Newbie
    Replies: 2
    Last Post: 27th February 2007, 11:48
  5. Simple Question on Variable initialization
    By Naveen in forum Qt Programming
    Replies: 3
    Last Post: 17th March 2006, 11:01

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.