Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. setFloating method isn't working
Qt 6.11 is out! See what's new in the release blog

setFloating method isn't working

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 872 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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?

    JonBJ 1 Reply Last reply
    0
    • ? A Former User

      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?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @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?

      ? 2 Replies Last reply
      2
      • JonBJ JonB

        @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?

        ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        @JonB Thank you for your response. I'm moving over from Java so this might be a problem I run into. What do you mean by normal ranges one expects?

        1 Reply Last reply
        0
        • JonBJ JonB

          @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?

          ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          @JonB Thank you very much; your advice helped me fix this problem!

          JonBJ 1 Reply Last reply
          0
          • ? A Former User

            @JonB Thank you very much; your advice helped me fix this problem!

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @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.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt
            • Unsolved