PDA

View Full Version : Moving widget to second screen not working



binaural
5th September 2012, 23:25
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:

#include <QtGui/QApplication>
#include "mainwindow.h"
#include "mainwindow_2.h"
#include <QDebug>
#include <QDesktopWidget>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
MainWindow_2 w2;

QDesktopWidget *widget = QApplication::desktop();
qDebug() << "Num of screens:" << widget->screenCount();

for (int i = 0; i < widget->screenCount(); i++) {
qDebug() << "Geometry:" << widget->screenGeometry(i);
}

QRect rect = widget->screenGeometry(1);
qDebug() << "Move to:" << rect.width() << ":" << rect.y();
w2.move(rect.width(), rect.y());

w.show();
w2.show();

return a.exec();
}

ChrisW67
6th September 2012, 10:17
You have two separate X servers not presenting a single virtual desktop. If it were a single virtual desktop you'd expect geometries like:


Num of screens: 2
Geometry: QRect(0,0 1024x768)
Geometry: QRect(1024,0 1024x768)

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:


./app -display :1
OR
DISPLAY=:1 ./app


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.

binaural
6th September 2012, 23:09
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/fb1:offset=656,0:1 :0" -nomouse

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


QRect rect = widget->screenGeometry(0);
qDebug() << "Move to:" << rect.width() << ":" << rect.y();
w2.move(rect.width(), 0);