windowState() doesn't retrun the enum Qt::WindowState?
From the documentation:
"Qt::WindowState QWindow::windowState() const
the screen-occupation state of the window
See also setWindowState() and windowStates()."
So isn't it supposed to return a Qt::WindowState?
Well this code fails.
.pro
Code:
QT+= widgets
HEADERS += \
mainwindow.h
SOURCES += \
main.cpp
mainwindow.h
Code:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
{
Q_OBJECT
public:
explicit MainWindow
(QWidget *parent
= nullptr
);
void getState();
signals:
public slots:
private:
Qt::WindowState m_state;
};
#endif // MAINWINDOW_H
main.cpp
Code:
#include <QApplication>
#include "mainwindow.h"
{
resize(400,400);
}
void MainWindow::getState()
{
m_state = windowState();
}
int main(int argc, char *argv[])
{
MainWindow window;
window.show();
return app.exec();
}
Compiler error:
Y:\QTProjects\Problems\myWindowState\main.cpp:12: error: C2440: '=': cannot convert from 'Qt::WindowStates' to 'Qt::WindowState'
Y:\QTProjects\Problems\myWindowState\main.cpp:12: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
What am I missing?
I need to be able to save m_state, and use it to setWindowState(m_state)
Re: windowState() doesn't retrun the enum Qt::WindowState?
Re: windowState() doesn't retrun the enum Qt::WindowState?
I see, I was looking at the documentation for the window class.
Re: windowState() doesn't retrun the enum Qt::WindowState?
Yes. So why do they call it QMainWindow instead of QMainWidget when it is actually a QWidget-based class? No wonder people have such a hard time with some parts of Qt.
Re: windowState() doesn't retrun the enum Qt::WindowState?