Page 1 of 1

QT: Incorrect Client Height with Menu

Posted: Wed Jan 07, 2026 9:05 pm
by matbal
Under Linux with the QT subsystem, the calculation of the client height of a window does not work correctly when the window has a menu.

With GTK, it is correct.

The bug has existed since version 6.12.

In the example code, you can enable or disable the menu, toolbar, and status bar using the three global variables to see the error. The EditorGadget should occupy almost the entire available space.

(my OS is Manjaro KDE)

Code: Select all

Global menu = 1         ; 1 = Create Menu 
Global statusbar = 0    ; 1 = Create Statusbar
Global toolbar = 0      ; 1 = Create Toolbar

Enumeration 
   #FormMain 
   #FormMain_Editor
   #MenuMain
   #MenuMain_Quit
   #StatusBar_Main
   #Timer_FirstResize
   #ToolbarMain
   #ToolbarMain_Button1
   #ToolbarMain_Button2
   #Image_Button1
EndEnumeration

Procedure FormMain_Resize()
   Protected x, y, w, h
   ; Editorgadget Size
   x = 5
   y = 5
   w = WindowWidth(#FormMain) - 10
   h = WindowHeight(#FormMain) - 10
   
   If menu 
      h - MenuHeight()
      ;h + 29
   EndIf
   If statusbar
      h - StatusBarHeight(#StatusBar_Main)
   EndIf
   If toolbar
      h - ToolBarHeight(#ToolbarMain)
   EndIf
   ResizeGadget(#FormMain_Editor, x, y, w, h)
EndProcedure

Procedure FormMain_Open()
   OpenWindow(#FormMain, 100, 100, 420, 320, "Window", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_Invisible)
   
   If menu
      CreateMenu(#MenuMain, WindowID(#FormMain))
      MenuTitle("File")
      MenuItem(#MenuMain_Quit, "Quit")
   EndIf
   
   If statusbar
      CreateStatusBar(#StatusBar_Main, WindowID(#FormMain))
      AddStatusBarField(#PB_Ignore)
      StatusBarText(#StatusBar_Main, 0, "Statusbartext")
   EndIf
   
   If toolbar
      CreateImage(#Image_Button1, 32, 32, 32, #Red)
      ResizeImage(#Image_Button1, 16, 16)
      CreateToolBar(#ToolbarMain, WindowID(#FormMain))
      ToolBarImageButton(#ToolbarMain_Button1, ImageID(#Image_Button1))
      ToolBarImageButton(#ToolbarMain_Button2, ImageID(#Image_Button1))
   EndIf
      
   EditorGadget(#FormMain_Editor, 0, 0, 0, 0)
   
   FormMain_Resize()
   HideWindow(#FormMain, 0)
EndProcedure


FormMain_Open()

Repeat
   event = WaitWindowEvent()
   If event = #PB_Event_SizeWindow And EventWindow() = #FormMain
      FormMain_Resize()
   EndIf
Until event = #PB_Event_CloseWindow