Important: Please read the Qt Code of Conduct -

Properties of the Qmainwindow don’t work

  • I created a qt gui application. added...
    @QMainWindow.setDisabled(false);@ to the mainwindow.cpp file

    ran it and got the error... mainwindow.cpp:9: error: expected unqualified-id before '.' token.
    I am trying to test out some of the properties of the Qmainwindow but they do not work. what i am doing wrong?

    @#include <QtGui/QApplication>
    #include "mainwindow.h"

    int main(int argc, char *argv[])
    QApplication a(argc, argv);
    MainWindow w;;

    return a.exec&#40;&#41;;


    @#include "mainwindow.h"
    #include "ui_mainwindow.h"

    MainWindow::MainWindow(QWidget *parent) :
    ui(new Ui::MainWindow)

    delete ui;

  • @QMainWindow.setDisabled(false);@
    Actually it's not about Qt. It's about C++.
    Try to replace it with:
    Or simply with:

  • if i wanted to use qmainwindow.setDisabled(false); in a different function outside of MainWindow::MainWindow that what would i use then?

  • Seems like you're totally new to C++ and OOP in general.
    Try to read some tutorials on C++ programming.

    MainWindow w;

  • yes I am fairly new to c++. I understand conditional statements and a bit of functions. thank you for your help.

  • Hi kalster,

    setDisabled is a method of the class QWidget and there fore also for each derived class.
    If you are inside the class (so inside the derived classes members) you can directly call it. If you are outside (or want to call it for another object) you have to use the target object as selector:

    MainWindow w;


    QCheckBox* pCheck;

Log in to reply