Results 1 to 5 of 5

Thread: windowState() doesn't retrun the enum Qt::WindowState?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2018
    Posts
    13
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default 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
    Qt Code:
    1. QT+= widgets
    2. HEADERS += \
    3. mainwindow.h
    4.  
    5. SOURCES += \
    6. main.cpp
    To copy to clipboard, switch view to plain text mode 

    mainwindow.h
    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QMainWindow>
    5.  
    6. class MainWindow : public QMainWindow
    7. {
    8. Q_OBJECT
    9. public:
    10. explicit MainWindow(QWidget *parent = nullptr);
    11. void getState();
    12. signals:
    13.  
    14. public slots:
    15. private:
    16. Qt::WindowState m_state;
    17. };
    18.  
    19. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

    main.cpp
    Qt Code:
    1. #include <QApplication>
    2.  
    3. #include "mainwindow.h"
    4.  
    5. MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
    6. {
    7. resize(400,400);
    8. }
    9.  
    10. void MainWindow::getState()
    11. {
    12. m_state = windowState();
    13. }
    14.  
    15. int main(int argc, char *argv[])
    16. {
    17. QApplication app(argc, argv);
    18. MainWindow window;
    19. window.show();
    20.  
    21. return app.exec();
    22. }
    To copy to clipboard, switch view to plain text mode 

    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)
    Last edited by shawnlau; 7th July 2018 at 18:46.

Similar Threads

  1. enum initialization
    By ad5xj in forum Qt Programming
    Replies: 3
    Last Post: 11th November 2015, 20:56
  2. enum to QString
    By bibhukalyana in forum Qt Programming
    Replies: 4
    Last Post: 22nd May 2013, 08:33
  3. QT enum array
    By angarali06 in forum Qt Programming
    Replies: 4
    Last Post: 3rd April 2011, 15:21
  4. SQLQUERY - column value retrun problem
    By damodharan in forum Qt Programming
    Replies: 7
    Last Post: 27th May 2010, 07:09
  5. windowState error Qt 3.3.4
    By tt in forum Qt Programming
    Replies: 3
    Last Post: 25th March 2006, 16:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.