Properties of the Qmainwindow don’t work
-
I created a qt gui application. added...
@QMainWindow.setDisabled(false);@ to the mainwindow.cpp fileran 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?main.cpp
@#include <QtGui/QApplication>
#include "mainwindow.h"int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();return a.exec();
}@
mainwindow.cpp
@#include "mainwindow.h"
#include "ui_mainwindow.h"MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QMainWindow.setDisabled(false);
}MainWindow::~MainWindow()
{
delete ui;
}@ -
@QMainWindow.setDisabled(false);@
Actually it's not about Qt. It's about C++.
Try to replace it with:
@this->setDisabled(false);@
Or simply with:
@setDisabled(false);@ -
Seems like you're totally new to C++ and OOP in general.
Try to read some tutorials on C++ programming.P.S.:
@
MainWindow w;
w.setDisabled(true);
@ -
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;
w.setDisabled(true);
@or
@
QCheckBox* pCheck;
pCheck->setDisabled(true);
@