setFloating method isn't working
-
Hello everyone, hope all is well! In regards to my last post (https://forum.qt.io/topic/128370/when-a-dock-widget-is-floating-how-to-reset-it-back-to-its-initial-area-when-a-button-is-pressed), I thought I was about to reach a solution:
void MainWindow::on_actiont2_triggered() { for (int i = 0; i <= dockCount; i++) { if (dockVector[i]->isFloating()) { dockVector[i]->setFloating(false); // not working } } }
My goal for this function is to place a floating dockWidget back into its starting dock widget area. However, when the button is triggered, the program crashes. After doing some testing and debugging, I realize that the setFloating method is causing this problem. What needs to be done to fix this?
-
@WesLow said in setFloating method isn't working:
the program crashes
dockVector[i]->setFloating(false); // not working
for (int i = 0; i <= dockCount; i++)
Given the normal ranges one expects in C/C++ coding, are you sure your loop termination condition is correct here?
-
@WesLow
I wanted you to look at the loop and see for yourself what was wrong! Even in Java I believe array indexing/loop counters range from 0 to length-1, it has become in most languages.