Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Properties of the Qmainwindow don’t work
QtWS25 Last Chance

Properties of the Qmainwindow don’t work

Scheduled Pinned Locked Moved C++ Gurus
6 Posts 3 Posters 2.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kalster
    wrote on last edited by
    #1

    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?

    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&#40;&#41;;
    

    }@

    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;
    }@

    1 Reply Last reply
    0
    • C Offline
      C Offline
      chernetsov0
      wrote on last edited by
      #2

      @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);@

      Programmer is an organism that can turn caffeine into code.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kalster
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • C Offline
          C Offline
          chernetsov0
          wrote on last edited by
          #4

          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);
          @

          Programmer is an organism that can turn caffeine into code.

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kalster
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #6

              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);
              @

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved