1 Attachment(s)
Having trouble maximizing my window - It resizes too large
I want my window to have four different modes:
- Fullscreen
- Maximized without a border (like fullscreen, but the taskbar is still visible)
- Maximized
- Windowed (non-resizable)
Windowed works fine, and maximized without a border works fine, but regular maximized isn't working.
Regular plain-vanilla Maximized is filling up the entire screen including under the taskbar.
Here's a screenshot showing what I mean:
Attachment 7360
(editted, to cut down on resolution by cutting out blank space)
I've tried multiple different ways of setting maximized, including:
Code:
QWidget::setWindowFlags(Qt
::Window);
QWidget::setWindowState(Qt
::WindowActive, Qt
::Maximized);
I also tried manually re-sizing it, and I tried using QWidget::showMaximized().
Here's my current code:
Code:
void MainWindow::_recalculateWindowSize()
{
//Undo any previous minimums and maximums.
QWidget::setMaximumSize(1000000,
1000000);
//Choose what settings to use, depending on WindowMode.
if(this->windowMode == Engine::WindowMode::Fullscreen)
{
QWidget::setWindowFlags(Qt
::Window);
QWidget::resize( qApp
->desktop
()->size
() );
}
else if(this->windowMode == Engine::WindowMode::Multitask)
{
QWidget::setWindowFlags(Qt
::Window | Qt
::FramelessWindowHint);
QRect desktopGeometry
= qApp
->desktop
()->availableGeometry
();
QWidget::resize(desktopGeometry.
size());
QWidget::move(desktopGeometry.
x(), desktopGeometry.
y());
QWidget::setWindowState(Qt
::WindowActive);
//Qt::Maximized }
else if(this->windowMode == Engine::WindowMode::Maximized)
{
QWidget::setWindowFlags(Qt
::Window);
//QWidget::setGeometry(qApp->desktop()->availableGeometry());
}
else //Engine::WindowMode::Windowed
{
WindowSize windowSize = this->_calculateWindowSizeWithEditor(this->requestedWindowSize);
QWidget::setWindowFlags(Qt
::Window | Qt
::WindowMinMaxButtonsHint);
QWidget::resize(windowSize.
ToQSize());
//QWidget::setFixedSize(windowSize.ToQSize());
QWidget::move(50,
50);
//Temp, haven't cent }
QWidget::show();
//Have to 'show()' to apply the new setWindowState() state. QWidget::grabKeyboard();
//Just incase we accidentally lost focus during the transition. }
MainWindow private inherits QWidget (but brings QObject into the public interface), and has no parent.
(Note: It's not a QMainWindow, if that matters. I have no QMainWindow, just a parentless QWidget)
Any ideas what I'm doing wrong?
Re: Having trouble maximizing my window - It resizes too large
Hello, quick question concerning the screenshot, is the windows taskbar set to auto hide? sometimes when thats the case the full screen is calculated as the space underneath the taskbar.
Re: Having trouble maximizing my window - It resizes too large
No, it's not set to autohide. If it was set to autohide, I'd like it to fill that taskbar space, but it's not set to that.
Thanks for the good question, though. =)