Spy++ doesn't reach button in Qt application
<p>I'm trying to get the properties of a button but when I drag the spy++'s find window tool it doesn't reach the button (of caption "iniciar gravação" in that case) but rather the button grid parent, like this:</p>

<p><a href="https://i.stack.imgur.com/ieY2I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ieY2I.png" alt="enter image description here"></a></p>

<p>Why is that and how can I get the button properties? I tried with auto it info tool but I get the same behavior.</p>

<p>I tried get that button properties from C# code, like this:</p>

<pre><code>    public class WindowHandleInfo
    {
        private delegate bool EnumWindowProc(IntPtr hwnd, IntPtr lParam);

        [DllImport("user32")]
        [return: MarshalAs(UnmanagedType.Bool)]
        private static extern bool EnumChildWindows(IntPtr window, EnumWindowProc callback, IntPtr lParam);

        private IntPtr _MainHandle;

        public WindowHandleInfo(IntPtr handle)
        {
            this._MainHandle = handle;
        }

        public List&lt;IntPtr&gt; GetAllChildHandles()
        {
            List&lt;IntPtr&gt; childHandles = new List&lt;IntPtr&gt;();

            GCHandle gcChildhandlesList = GCHandle.Alloc(childHandles);
            IntPtr pointerChildHandlesList = GCHandle.ToIntPtr(gcChildhandlesList);

            try
            {
                EnumWindowProc childProc = new EnumWindowProc(EnumWindow);
                EnumChildWindows(this._MainHandle, childProc, pointerChildHandlesList);
            }
            finally
            {
                gcChildhandlesList.Free();
            }

            return childHandles;
        }

        private bool EnumWindow(IntPtr hWnd, IntPtr lParam)
        {
            GCHandle gcChildhandlesList = GCHandle.FromIntPtr(lParam);

            if (gcChildhandlesList == null || gcChildhandlesList.Target == null)
            {
                return false;
            }

            List&lt;IntPtr&gt; childHandles = gcChildhandlesList.Target as List&lt;IntPtr&gt;;
            childHandles.Add(hWnd);

            return true;
        }
    }


 void printWindows(IntPtr parent, int tabLevel)
        {
            var w = new WindowHandleInfo(parent);
            foreach (IntPtr h in w.GetAllChildHandles())
            {
                string caption = GetTextBoxText(h) ?? "not found";
                Debug.Write(new string('\t', tabLevel));
                Debug.WriteLine(caption);
                printWindows(h, tabLevel + 1);
            }
        }

 int GetTextBoxTextLength(IntPtr hTextBox)
        {
            // helper for GetTextBoxText
            const int WM_GETTEXTLENGTH = 0x000E;
            int result = SendMessage(hTextBox, WM_GETTEXTLENGTH, 0, IntPtr.Zero);
            return result;
        }

        string GetTextBoxText(IntPtr hTextBox)
        {
            const int WM_GETTEXT = 0x000D;
            int len = GetTextBoxTextLength(hTextBox);
            if (len &lt;= 0) return null;  // no text
            StringBuilder sb = new StringBuilder(len + 1);
            SendMessage(hTextBox, WM_GETTEXT, len + 1, sb);
            return sb.ToString();
        }
</code></pre>

<p>using like this:</p>

<pre><code> IntPtr parent = FindWindow(IntPtr.Zero, "my app title");
 printWindows(parent, 0);
</code></pre>

<p>But I can't see anyhing related to <em>Iniciar gravação</em> button.</p>