Results 1 to 3 of 3

Thread: Desktop Dual Screen in Ubuntu 10.04, get screen width and height not coherent.

  1. #1
    Join Date
    Jun 2010
    Posts
    36
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Desktop Dual Screen in Ubuntu 10.04, get screen width and height not coherent.

    I'm using official nvidia drivers with twin view and I noticed sizes are not right.

    Qt Code:
    1. int w0 = desktop.screen(0)->width();
    2. int h0 = desktop.screen(0)->height();
    3. int w1 = desktop.screen(1)->width();
    4. int h1 = desktop.screen(1)->height();
    5.  
    6. std::cout << desktop.numScreens() << std::endl;
    7. std::cout << w0 << " : " << h0 << std::endl;
    8. std::cout << w1 << " : " << h1 << std::endl;
    To copy to clipboard, switch view to plain text mode 

    output:
    2
    3600 : 1200
    3600 : 1200

    My monitor configuration is 1920 1200 and 1680 1050. Obviously the sizes are merged. Is this a normal behavior? How can I get independent sizes?

    This is somewhat of a problem since I wanted to fit the window in the center on the first screen...

    Thanks

  2. #2
    Join Date
    Mar 2008
    Location
    Houston, Texas, USA
    Posts
    277
    Thanks
    9
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: Desktop Dual Screen in Ubuntu 10.04, get screen width and height not coherent.

    This works for me and I'm using dual monitors.

    Qt Code:
    1. #include <QtCore/QtCore>
    2. #include <QtGui/QtGui>
    3.  
    4. int main(int argc, char** argv)
    5. {
    6. new QApplication(argc, argv);
    7.  
    8. QDesktopWidget desktop;
    9. for (int i = 0; i < desktop.screenCount(); ++i) {
    10. qDebug() << "Width: " << desktop.screenGeometry(i).width();
    11. qDebug() << "Height: " << desktop.screenGeometry(i).height();
    12. }
    13.  
    14. return QApplication::exec();
    15. }
    To copy to clipboard, switch view to plain text mode 
    Qt-4.7.3 | Gentoo ~amd64 | KDE-4.7
    Aki IRC Client for KDE4 | Qt Documentation

  3. #3
    Join Date
    Jun 2010
    Posts
    36
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Desktop Dual Screen in Ubuntu 10.04, get screen width and height not coherent.

    Right on the spot. Thanks.

Similar Threads

  1. Replies: 3
    Last Post: 13th May 2010, 09:20
  2. Replies: 2
    Last Post: 25th February 2010, 11:28
  3. QLayout: different SizeConstraints for width and height?
    By PhilippB in forum Qt Programming
    Replies: 0
    Last Post: 23rd February 2009, 17:33
  4. Pixmap height / width without loading it
    By bunjee in forum Qt Programming
    Replies: 1
    Last Post: 29th November 2007, 08:10
  5. width and height of QTabWidget
    By chikkireddi in forum Qt Programming
    Replies: 6
    Last Post: 29th October 2007, 14:53

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.