Issue with setHorizontalScrollBarPolicy in MDI area.
-
Wheneve the main Widget is Maximized state at that time Scrollbar is not appear. But if main window is in NoSate (Restore Down) at that time scrollbar is appear. I don't want to change the size of Subwindow.Here I put sample code, which is similar to my project code.
#include "MDIarea.h"
#include <qpushbutton.h>
#include <qlayout.h>
#include <qmdiarea.h>
MDIarea::MDIarea(QWidget *parent)
: QMainWindow(parent)
{
QWidget *w = nullptr;
w = new QWidget;
w->setWindowTitle("hello");
w->show();QPushButton *tilepbt; auto mdiArea = new QMdiArea; mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); auto vgrid = new QVBoxLayout(w); auto forbutton = new QHBoxLayout(); auto layout = new QHBoxLayout(); layout->addWidget(mdiArea); QWidget *wl = nullptr; wl = new QWidget; wl->setMinimumHeight(350); mdiArea->addSubWindow(wl); mdiArea->addSubWindow(wl); mdiArea->addSubWindow(wl); mdiArea->addSubWindow(wl); mdiArea->addSubWindow(wl); mdiArea->addSubWindow(wl); mdiArea->addSubWindow(wl); mdiArea->addSubWindow(wl); forbutton->addWidget(tilepbt = new QPushButton("tile")); vgrid->addLayout(forbutton); vgrid->addLayout(layout); QList<QMetaObject::Connection> m_connections; m_connections << QObject::connect(tilepbt, &QPushButton::clicked, mdiArea, &QMdiArea::tileSubWindows);
}
Complier Output:
MDI area.exe' (Win32): Loaded 'F:\Qt with Visula studio\Mdi area\MDI area\Win32\Debug\MDI area.exe'. Symbols loaded.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shell32.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ucrtbase.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Qt\Qt5.6.3\5.6.3\msvc2015\bin\Qt5Cored.dll'. Symbols loaded.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp140d.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\vcruntime140d.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Qt\Qt5.6.3\5.6.3\msvc2015\bin\Qt5Widgetsd.dll'. Symbols loaded.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\SHCore.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ucrtbased.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32full.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\win32u.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp_win.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\combase.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Qt\Qt5.6.3\5.6.3\msvc2015\bin\Qt5Guid.dll'. Symbols loaded.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcryptprimitives.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\windows.storage.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shlwapi.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel.appcore.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\advapi32.dll'
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\powrprof.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\profapi.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ws2_32.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\mpr.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\tmumh\20019\AddOn\7.0.0.1137\TmUmEvt.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\psapi.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\tmumh\20019\TmMon\2.5.0.2070\tmmon.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Qt\Qt5.6.3\5.6.3\msvc2015\plugins\platforms\qwindowsd.dll'. Symbols loaded.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\oleaut32.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmm.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmmbase.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\uxtheme.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Program Files (x86)\Common Files\microsoft shared\ink\tiptsf.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dwmapi.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\clbcatq.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\DataExchange.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\d3d11.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dcomp.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dxgi.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\twinapi.appcore.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rmclient.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcrypt.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\TextInputFramework.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\CoreUIComponents.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\CoreMessaging.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntmarta.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\WinTypes.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Qt\Qt5.6.3\5.6.3\msvc2015\plugins\imageformats\qgifd.dll'. Symbols loaded.
'MDI area.exe' (Win32): Loaded 'C:\Qt\Qt5.6.3\5.6.3\msvc2015\plugins\imageformats\qicnsd.dll'. Symbols loaded.
'MDI area.exe' (Win32): Loaded 'C:\Qt\Qt5.6.3\5.6.3\msvc2015\plugins\imageformats\qicod.dll'. Symbols loaded.
'MDI area.exe' (Win32): Loaded 'C:\Qt\Qt5.6.3\5.6.3\msvc2015\plugins\imageformats\qjpegd.dll'. Symbols loaded.
'MDI area.exe' (Win32): Loaded 'C:\Qt\Qt5.6.3\5.6.3\msvc2015\plugins\imageformats\qsvgd.dll'. Symbols loaded.
'MDI area.exe' (Win32): Loaded 'C:\Qt\Qt5.6.3\5.6.3\msvc2015\bin\Qt5Svgd.dll'. Symbols loaded.
'MDI area.exe' (Win32): Loaded 'C:\Qt\Qt5.6.3\5.6.3\msvc2015\plugins\imageformats\qtgad.dll'. Symbols loaded.
'MDI area.exe' (Win32): Loaded 'C:\Qt\Qt5.6.3\5.6.3\msvc2015\plugins\imageformats\qtiffd.dll'. Symbols loaded.
'MDI area.exe' (Win32): Loaded 'C:\Qt\Qt5.6.3\5.6.3\msvc2015\plugins\imageformats\qwbmpd.dll'. Symbols loaded.
'MDI area.exe' (Win32): Loaded 'C:\Qt\Qt5.6.3\5.6.3\msvc2015\plugins\imageformats\qwebpd.dll'. Symbols loaded.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\UIAutomationCore.dll'. Cannot find or open the PDB file.
onecore\com\combase\inc\comcataloghelpers.hpp(67)\combase.dll!74A18550: (caller: 74A182E0) ReturnHr(1) tid(1a70) 80004002 No such interface supported
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sxs.dll'. Cannot find or open the PDB file.
mincore\com\oleaut32\dispatch\ups.cpp(2125)\OLEAUT32.dll!770E234F: (caller: 770E1EF1) ReturnHr(1) tid(3898) 8002801D Library not registered.
mincore\com\oleaut32\dispatch\ups.cpp(2125)\OLEAUT32.dll!770E234F: (caller: 770E1EF1) ReturnHr(2) tid(3898) 8002801D Library not registered.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\oleacc.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Program Files (x86)\WordWeb\WHook.dll'. Cannot find or open the PDB file.
'MDI area.exe' (Win32): Loaded 'C:\Windows\SysWOW64\version.dll'. Cannot find or open the PDB file.
QWindowsWindow::setGeometry: Unable to set geometry 1366x1208+0+23 on QWidgetWindow/'QWidgetClassWindow'. Resulting geometry: 1366x705+0+23 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 182x120, maximum size: 16777215x16777215).
QWindowsWindow::setGeometry: Unable to set geometry 1366x1208+0+23 on QWidgetWindow/'QWidgetClassWindow'. Resulting geometry: 1366x705+0+23 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 182x120, maximum size: 16777215x16777215).
QWindowsWindow::setGeometry: Unable to set geometry 640x1208+363+124 on QWidgetWindow/'QWidgetClassWindow'. Resulting geometry: 640x1061+363+124 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 182x120, maximum size: 16777215x16777215).
QWindowsWindow::setGeometry: Unable to set geometry 640x1208+363+124 on QWidgetWindow/'QWidgetClassWindow'. Resulting geometry: 640x1061+363+124 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 182x120, maximum size: 16777215x16777215).for more clarification to see the error.
- run the code and maximized the window and clicked on tile button
-here you will not see the Scrollbar.
2)now Minimized the window- now you can see the scrollbar.
- Maximized the window
- now you can see the scrollbar. but if you click on tile button then again it will disappear.
- run the code and maximized the window and clicked on tile button
-
step for getting error
- run the code and maximized the window and clicked on tile button
-here you will not see the Scrollbar.
2)now Minimized the window
now you can see the scrollbar.
3)Maximized the window
now you can see the scrollbar. but if you click on tile button then again it will disappear.
- run the code and maximized the window and clicked on tile button
-
Hi
Tried to run the code in
Qt5.10 on win 10 and didn't see a scrollbar at all.You could try newest Qt and see if any difference.
-
Thank you mrjj for support. Here I found the another way to setup the widget into MDI area. http://blog.qt.io/blog/2013/04/29/how-to-tile-widgets-in-a-multiple-document-interface-application/
-
So that fixes the scrollbar issue ?
-
ok super.
Its good to see someone still using MDI in 2018 :)