How to auto resize widget height when dragged to a smaller monitor ?
I have two monitors, one 3840x2160 (main) and one 1680x1050 (secondary).
After dragging a full-height widget from main to secondary monitor, the widgets keeps its sizes and is much too tall for the new monitor.
How to auto resize the widget on the secondary monitor accordingly ?
@QtVik Do you use layouts?
This post is deleted!
This post is deleted!
Basically I have created several QWidget/QGLWidget as plugins in my Qt application.
It is possible to dock/undock these widgets.
When I undock any of these widgets I can move it to another screen individually.
Note: I do not use Qt designer here.
Hi, you can try like this,
void Widget::moveEvent(QMoveEvent * e)
m_newScreenSize = qApp->desktop()->screenGeometry(this);
void Widget::mouseReleaseEvent(QMouseEvent * e)
I tried it but the issue still persists.
Mouse release event gets invoked only when you mouse click in widget area but not in title bar of the widget.
I am trying to move the widget holding on widget's title bar area.
Above changes doesn't make any difference in behavior(still the window height is too tall for the smaller screen).
Have you given any fixed sizes to widgets?
No.. I haven't set any fixed size widget!
Please show the sample code..
The title bar is not the region of the
QWidget. Because it is a Window's region, it can not be implemented using
nativeEvent (). If you are on Windows, you can use messages like
Thank you guys!
It worked for me. Actually i was handling mousePress event in the titleBar class which i had to update in my main class through widgetFocusEvent.
@Vinod-Kuntoji: Your input helped me a lot.Thank you.
As I move the widget to smaller monitor the title bar is getting hidden.
How to reset the position of the widget while moving to second screen ?
Example: The top border of my widget that i am moving from bigger monitor should align with top border of the smaller monitor. Now it is getting hidden unfortunately.
Please show your code so we can see
what you did with nativeEvent()
Also what titleBar class ??
Are you using custom border and caption ?
@mrjj I haven't done anything using nativeEvent() yet. Will try it and update.