Results 1 to 3 of 3

Thread: Moving widget to second screen not working

  1. #1
    Join Date
    May 2009
    Posts
    55
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Moving widget to second screen not working

    Hi,

    I have raspberry pi with 2 screens (first is composite from RPI second is usb to vga (displaylink)).
    I have test app to display different text on both screens but if I run binary it always show text from
    first widget on both screens. MainWindow and MainWindow_2 are just basic main widgets with qlabel
    with different text.

    I'm running my app with:
    ./test_dual -qws -display "multi: linuxfb:/dev/fb0 linuxfb:/dev/fb1" -nomouse
    Num of screens: 2
    Geometry: QRect(0,0 656x416)
    Geometry: QRect(0,0 1680x1050)
    Move to: 1680 : 0

    I'm I missing something or it's just bug? I'm using Qt 4.8.2 compiled for ARM.

    Thanks,

    marek

    code snippet:
    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "mainwindow.h"
    3. #include "mainwindow_2.h"
    4. #include <QDebug>
    5. #include <QDesktopWidget>
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication a(argc, argv);
    9. MainWindow w;
    10. MainWindow_2 w2;
    11.  
    12. QDesktopWidget *widget = QApplication::desktop();
    13. qDebug() << "Num of screens:" << widget->screenCount();
    14.  
    15. for (int i = 0; i < widget->screenCount(); i++) {
    16. qDebug() << "Geometry:" << widget->screenGeometry(i);
    17. }
    18.  
    19. QRect rect = widget->screenGeometry(1);
    20. qDebug() << "Move to:" << rect.width() << ":" << rect.y();
    21. w2.move(rect.width(), rect.y());
    22.  
    23. w.show();
    24. w2.show();
    25.  
    26. return a.exec();
    27. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Moving widget to second screen not working

    You have two separate X servers not presenting a single virtual desktop. If it were a single virtual desktop you'd expect geometries like:
    Qt Code:
    1. Num of screens: 2
    2. Geometry: QRect(0,0 1024x768)
    3. Geometry: QRect(1024,0 1024x768)
    To copy to clipboard, switch view to plain text mode 
    Where the second screen's left edge is displaced to the right of the first. The window would then be movable into the space occupied by the second monitor.

    To start an app on the second screen you can do:
    Qt Code:
    1. ./app -display :1
    2. OR
    3. DISPLAY=:1 ./app
    To copy to clipboard, switch view to plain text mode 

    Edit: This is generic Linux advice. I don't have a dual head embedded system to play with. I also have not seen the "multi" syntax, so I am guessing that you get two displays.

  3. #3
    Join Date
    May 2009
    Posts
    55
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Moving widget to second screen not working

    Problem solved, maybe help others. Thanks ChrisW67 for ideas. Need to read manual properly

    I've check again configuration and code and following is working fine:

    /usr/bin/songPresentation -qws -display "multi: LinuxFb:/dev/fb0:0 LinuxFb:/dev/fb1ffset=656,0:1 :0" -nomouse

    and in code change (get geometry of first screen and mode second widget to that screen correctly).

    Qt Code:
    1. QRect rect = widget->screenGeometry(0);
    2. qDebug() << "Move to:" << rect.width() << ":" << rect.y();
    3. w2.move(rect.width(), 0);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. custom widget that contains moving parts
    By cgyan1 in forum Qt Programming
    Replies: 2
    Last Post: 14th February 2012, 15:47
  2. mouseMoveEvent: KDE moving widget
    By NullPointer in forum Newbie
    Replies: 1
    Last Post: 17th August 2011, 14:57
  3. Moving QObject to QThread causes signals to stop working
    By Ban-chan in forum Qt Programming
    Replies: 8
    Last Post: 13th July 2010, 21:39
  4. Moving left and right on the screen
    By Benjamin in forum Qt Programming
    Replies: 6
    Last Post: 21st June 2009, 19:09
  5. [Qt4] - Moving Widget...
    By IPFreely in forum Qt Programming
    Replies: 1
    Last Post: 13th June 2006, 09:32

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
  •  
Qt is a trademark of The Qt Company.