PDA

View Full Version : Setting QWidget full screen problem with 2 monitos



lni
10th January 2013, 14:34
Hi,

My machine has 2 monitors, I use QWidget::showFullScreen, but it only covers one monitor. I use setGeometry( QRectF( 0, 0, 3840, 1200 ) ), it still shows up in one screen. I have to manually resize the widget to cover both screens.

The QDesktopWidget::availableGeometry return QRect( 0, 0, 1920, 1200 ) and QRect( 1920, 0, 1920, 1200 ).

Is there a way to set QWidget to fully cover both screens inside the code?

Thanks.

lni
21st July 2013, 04:16
Anyone please?

ChrisW67
21st July 2013, 23:00
Have you tried setGeometry() or separate move() and resize() calls after the window is shown?

lni
24th July 2013, 04:32
I did both, as in the following codes, both w1 & w2 are only showing in one screen. Any ideas? Thanks



#include <QApplication>
#include <QWidget>

int main( int argc, char** argv )
{
QApplication app( argc, argv );

QWidget w1;
w1.setWindowTitle( "w1" );
w1.setGeometry( QRect( 0, 0, 3840, 1200 ) );
w1.show();

QWidget w2;
w2.setWindowTitle( "w2" );
w2.resize( 3840, 1200 );
w2.move( 0, 0 );
w2.show();

return app.exec();
}

ChrisW67
24th July 2013, 04:43
You are not calling setGeometry(), resize(), or move() after the window is shown. Try this:


#include <QApplication>
#include <QWidget>
#include <QTimer>

class Widget: public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *p = 0): QWidget(p) {
QTimer::singleShot(0, this, SLOT(afterShow()));
}
private slots:
void afterShow() {
setGeometry( QRect( 0, 0, 3840, 1200 ) );
// or
// move(0, 0);
// resize(3840, 1200);
}
};

int main( int argc, char** argv )
{
QApplication app( argc, argv );
Widget w;
w.show();
return app.exec();
}
#include "main.moc"

I don't have a dual screen setup to test.

lni
31st August 2013, 06:33
Still same problem...showing in one screen only.