Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. setFloating method isn't working

setFloating method isn't working

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 449 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 9 Jul 2021, 15:23 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?

    J 1 Reply Last reply 9 Jul 2021, 19:01
    0
    • ? A Former User
      9 Jul 2021, 15:23

      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?

      J Offline
      J Offline
      JonB
      wrote on 9 Jul 2021, 19:01 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 9 Jul 2021, 23:25
      2
      • J JonB
        9 Jul 2021, 19:01

        @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 9 Jul 2021, 23:25 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
        • J JonB
          9 Jul 2021, 19:01

          @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 9 Jul 2021, 23:37 last edited by
          #4

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

          J 1 Reply Last reply 10 Jul 2021, 07:03
          0
          • ? A Former User
            9 Jul 2021, 23:37

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

            J Offline
            J Offline
            JonB
            wrote on 10 Jul 2021, 07:03 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

            1/5

            9 Jul 2021, 15:23

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved