Hello there,
I have two questions:
1. How to remove this border from the main window:
2. How can I move my window from my "Title frame" ?
I'm trying with mouseMoveEvent, but my calculations are wrong.
Thanks to all.
Hello there,
I have two questions:
1. How to remove this border from the main window:
2. How can I move my window from my "Title frame" ?
I'm trying with mouseMoveEvent, but my calculations are wrong.
Thanks to all.
- See Qt::FramelessWindowHint
- See wiki article: [WIKI]Moving widgets[/WIKI]
J-P Nurmi
Kostanev (30th March 2008)
Hello, I followed the tutorial, on first look seems to work fine but when I click on a some control like button or slider and I move the mouse the main window start to jump and the mouse is moved to the top left corner of the window. Any fix for this ?![]()
Anyone, please.
Cant really tell without seeing what you are doing.
Can we see what are you doing ?
post some code, please.
The problem seems to be that QSlider basically always accepts mouse press events but ignores mouse move events in case the user pressed outside the slider handle. Furthermore, ignored events are propagated to the parent, which means that the window doesn't receive a press event but a move event directly, thus offset is not calculated and the window jumps to wrong location. One solution could be to subclass and ensure that appropriate events are accepted. I guess you wouldn't like to move the window by dragging from a slider.
Qt Code:
{ event->accept(); }To copy to clipboard, switch view to plain text mode
J-P Nurmi
The code is in to the wiki page that the link is above, I do it in the very same way by subclassing QMainWindow.
@jpn Yes I don't want the window to move when I'm clicking some of the components like the slider, but if I inherit all of them I will not be able to use the Qt Designer at all.![]()
Actually you can (check the link) but it won't be very convenient...![]()
J-P Nurmi
Well maybe is possible some hack to ignore the move event if a press event hasn't been called ?![]()
Done, it works perfect with just one more bool variable.
Here's the result of code
Qt Code:
{ event->accept(); // do not propagate if (isWindow()) offset = event->globalPos() - pos(); else offset = event->pos(); MousePressEventCalled = true; } { event->accept(); // do not propagate MousePressEventCalled = false; } { if (!MousePressEventCalled) { event->ignore(); return; } event->accept(); // do not propagate if (isWindow()) move(event->globalPos() - offset); else move(mapToParent(event->pos() - offset)); }To copy to clipboard, switch view to plain text mode
Bookmarks