c++ - Show Mainwindow in the right of the screen (Qt 5.1.0) -


i want show mainwindow in right side of screen.

i use code :

qrect r  = this->framegeometry();    r.moveright(qdesktopwidget::availablegeometry());    this->move(r.topright()); 

and receive error :

error: cannot call member function 'const qrect qdesktopwidget::availablegeometry(int) const' without object

if use 1024 instead qdesktopwidget::availablegeometry() works... don't want initialize staticly...

how can dynamically reposition window different screen sizes?

qdesktopwidget::availablegeometry not static function. can use qapplication::desktop() function qdesktopwidget object:

qrect r  = this->framegeometry(); r.moveright(qapplication::desktop()->availablegeometry());  

you have put else in moveright() function. can't put qrect there. maybe want is:

qrect r = qapplication::desktop()->availablegeometry(); r.setleft(r.center().x()); this->resize(r.width(), r.height()); this->move(r.topleft()); 

or if don't want resize window:

qrect r = qapplication::desktop()->availablegeometry(); qrect main_rect = this->geometry(); main_rect.movetopright(r.topright()); this->move(main_rect.topleft()); 

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -