I'm new to Qt and I don't know how to fix this. I have a QDockWidget that is put in some position when the user clicks the undock button (I don't know it's name). When this happens the widget visibility changes twice because it sort of disappears and appears again but undocked. To put it in some position after it gets undocked I use this in the visibility changed event:
if (ui->searchBar->isFloating()) {
int x = (this->x() + this->width()) - 410;
int y = (this->y() + this->height()) - 70;
ui->searchBar->setGeometry(QRect(x,y,400,60));
}
The problem is that in Linux if I undock the widget by dragging it in stead of clicking the undock button, when I drop it in some place of the window it automatically moves to the position specified by the code above. It makes sense, however this doesn't happens in Windows(and I need the application to run in both OS). In Windows if you click the button it goes to the specified location but if you drag it then it stays in the position where you drop it.
To fix it I plan to use the above code only if the widget was not dragged but I'm not sure how to do this. Can somebody help me out or have a better idea on how to fix this?