Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. "does not refer to a value" error
Forum Update on Monday, May 27th 2025

"does not refer to a value" error

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 730 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by Anonymous_Banned275
    #1

    ADDENDUM
    OK, I had a chance to read similar post.
    It sort of explains that "connect" needs to refer to an instance of the object.

    This is my code "hierarchy"

    Main project ( QWindow()
    mdiArea with menu ( bar) - main ":window"
    selected menu (QWiidget) - child sub window
    selected submenu (QDialog) - free floating form

    My task is to copy / move the "selected submenu" dialog (GUI) to the main window as a new subwindow.

    my connect should look like this is - in pseudo code

    connect ( selected submenu, emit SIGNAl, main window , SLOT addSubwindow )

    In the above described hierarchy - what is the "instance " of the main "window"?

    My actual code

    connect(this,SIGNAL(addSubwindow()),MainWindow,SLOT(newSubWindow()));

    passes by compiler with the exception of "MainWindow" .

    Again - I do not get how to determine / code the actual instance of "MainWindow".

    What is confusing me is the code hierarchy when the final subMenu dialog is still running as part of the "MainWindow".

    I am unimpressed with "new" format .

    Is it over the developer's head to fix stuff instead of making irrelevant "cute" changes?

    I can highlight my title and get a list of similar posts BUT I cannot open any of them.
    ..and I cannot do "search" until I am done "submitting" my current post.

    ANS NO , I am not submitting bug report - if "you - owners of this forum " want to have crappy forum it is your business.

    So I will post this and than do a search for similar problems....

    What does "does not refer to a value" mean is irrelevant - how do I fix it?

    22515fc6-46ff-4435-83ba-c316e14ff214-image.png strikethrough text

        // event void MainWindow::newSubWindow(void)
            connect(this,SIGNAL(addSubwindow()),MainWindow,SLOT(newSubWindow()));
                    //&MainWindow,SLOT(newSubWindow()));
            emit addSubwindow(1);
    
    /mnt/07b7c3f8-0efb-45ab-8df8-2a468771de1f/PROJECTS/RECOVERY/BLUETOOTH/SOURCE/CCC_SOURCE/terminal_SERIAL_BLUETOOTH_VER_1/terminal_SERIAL_BLUETOOTH/terminal_BLUETOOTH/mainwindow_BT_Terminal.cpp:1440: error: 'MainWindow' does not refer to a value
    mainwindow_BT_Terminal.cpp:1440:45: error: 'MainWindow' does not refer to a value
            connect(this,SIGNAL(addSubwindow()),MainWindow,SLOT(newSubWindow()));
                                                ^
    ../../../FT857_library/../MAIN_MDI/mainwindows/mdi/mainwindow.h:67:7: note: declared here
    class MainWindow : public QMainWindow    // declaration
          ^
    
    Pl45m4P 2 Replies Last reply
    0
    • A Anonymous_Banned275

      ADDENDUM
      OK, I had a chance to read similar post.
      It sort of explains that "connect" needs to refer to an instance of the object.

      This is my code "hierarchy"

      Main project ( QWindow()
      mdiArea with menu ( bar) - main ":window"
      selected menu (QWiidget) - child sub window
      selected submenu (QDialog) - free floating form

      My task is to copy / move the "selected submenu" dialog (GUI) to the main window as a new subwindow.

      my connect should look like this is - in pseudo code

      connect ( selected submenu, emit SIGNAl, main window , SLOT addSubwindow )

      In the above described hierarchy - what is the "instance " of the main "window"?

      My actual code

      connect(this,SIGNAL(addSubwindow()),MainWindow,SLOT(newSubWindow()));

      passes by compiler with the exception of "MainWindow" .

      Again - I do not get how to determine / code the actual instance of "MainWindow".

      What is confusing me is the code hierarchy when the final subMenu dialog is still running as part of the "MainWindow".

      I am unimpressed with "new" format .

      Is it over the developer's head to fix stuff instead of making irrelevant "cute" changes?

      I can highlight my title and get a list of similar posts BUT I cannot open any of them.
      ..and I cannot do "search" until I am done "submitting" my current post.

      ANS NO , I am not submitting bug report - if "you - owners of this forum " want to have crappy forum it is your business.

      So I will post this and than do a search for similar problems....

      What does "does not refer to a value" mean is irrelevant - how do I fix it?

      22515fc6-46ff-4435-83ba-c316e14ff214-image.png strikethrough text

          // event void MainWindow::newSubWindow(void)
              connect(this,SIGNAL(addSubwindow()),MainWindow,SLOT(newSubWindow()));
                      //&MainWindow,SLOT(newSubWindow()));
              emit addSubwindow(1);
      
      /mnt/07b7c3f8-0efb-45ab-8df8-2a468771de1f/PROJECTS/RECOVERY/BLUETOOTH/SOURCE/CCC_SOURCE/terminal_SERIAL_BLUETOOTH_VER_1/terminal_SERIAL_BLUETOOTH/terminal_BLUETOOTH/mainwindow_BT_Terminal.cpp:1440: error: 'MainWindow' does not refer to a value
      mainwindow_BT_Terminal.cpp:1440:45: error: 'MainWindow' does not refer to a value
              connect(this,SIGNAL(addSubwindow()),MainWindow,SLOT(newSubWindow()));
                                                  ^
      ../../../FT857_library/../MAIN_MDI/mainwindows/mdi/mainwindow.h:67:7: note: declared here
      class MainWindow : public QMainWindow    // declaration
            ^
      
      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @AnneRanch said in "does not refer to a value" error:

      connect(this,SIGNAL(addSubwindow()),MainWindow,SLOT(newSubWindow()));

      It seems that MainWindow is not the name of your object of MainWindow class.
      If you are IN your MainWindow class, use this or the proper name of your MainWindow object, if you don't.

      BTW:
      You still don't like the "new" (actually not new anymore) connection style, don't you?! :)

      BTW:
      Your whole post is a mess and hard to understand. Non formatted code snippets between questions and other text, confusing images and more stuff.
      Not offensive, but sometimes it's hard to understand what are you asking for :)

      To answer your question, what to put in your connect statement instead of MainWindow, you have to look where you create it (Or show the relevant part of the code, at least).


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      1
      • A Offline
        A Offline
        Anonymous_Banned275
        wrote on last edited by
        #3

        @Pl45m4 Of course the post is a mess. It is peculiar that "they" cannot fix the "search" ...it has been an issue for years. It is unreasonable to expect the user to jump thru hoops to get thing posted - so GIGO...

        No, II have no issues with "new " connect , but I am using OLD examples and THEY still use it , so ....
        ( I only which people likes you quit pushing it - it is my business...

        Yes, my main window is named "MainWindow" and the solution was to use an instance of it and I have no idea HOW to put it in code.

        I was assuming that "this" belongs to the object where "connect" is coded , hence I do not want to run "SLOT" in THAT object.

        1 Reply Last reply
        0
        • A Anonymous_Banned275

          ADDENDUM
          OK, I had a chance to read similar post.
          It sort of explains that "connect" needs to refer to an instance of the object.

          This is my code "hierarchy"

          Main project ( QWindow()
          mdiArea with menu ( bar) - main ":window"
          selected menu (QWiidget) - child sub window
          selected submenu (QDialog) - free floating form

          My task is to copy / move the "selected submenu" dialog (GUI) to the main window as a new subwindow.

          my connect should look like this is - in pseudo code

          connect ( selected submenu, emit SIGNAl, main window , SLOT addSubwindow )

          In the above described hierarchy - what is the "instance " of the main "window"?

          My actual code

          connect(this,SIGNAL(addSubwindow()),MainWindow,SLOT(newSubWindow()));

          passes by compiler with the exception of "MainWindow" .

          Again - I do not get how to determine / code the actual instance of "MainWindow".

          What is confusing me is the code hierarchy when the final subMenu dialog is still running as part of the "MainWindow".

          I am unimpressed with "new" format .

          Is it over the developer's head to fix stuff instead of making irrelevant "cute" changes?

          I can highlight my title and get a list of similar posts BUT I cannot open any of them.
          ..and I cannot do "search" until I am done "submitting" my current post.

          ANS NO , I am not submitting bug report - if "you - owners of this forum " want to have crappy forum it is your business.

          So I will post this and than do a search for similar problems....

          What does "does not refer to a value" mean is irrelevant - how do I fix it?

          22515fc6-46ff-4435-83ba-c316e14ff214-image.png strikethrough text

              // event void MainWindow::newSubWindow(void)
                  connect(this,SIGNAL(addSubwindow()),MainWindow,SLOT(newSubWindow()));
                          //&MainWindow,SLOT(newSubWindow()));
                  emit addSubwindow(1);
          
          /mnt/07b7c3f8-0efb-45ab-8df8-2a468771de1f/PROJECTS/RECOVERY/BLUETOOTH/SOURCE/CCC_SOURCE/terminal_SERIAL_BLUETOOTH_VER_1/terminal_SERIAL_BLUETOOTH/terminal_BLUETOOTH/mainwindow_BT_Terminal.cpp:1440: error: 'MainWindow' does not refer to a value
          mainwindow_BT_Terminal.cpp:1440:45: error: 'MainWindow' does not refer to a value
                  connect(this,SIGNAL(addSubwindow()),MainWindow,SLOT(newSubWindow()));
                                                      ^
          ../../../FT857_library/../MAIN_MDI/mainwindows/mdi/mainwindow.h:67:7: note: declared here
          class MainWindow : public QMainWindow    // declaration
                ^
          
          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by
          #4

          @AnneRanch said in "does not refer to a value" error:

          // event void MainWindow::newSubWindow(void)
          connect(this,SIGNAL(addSubwindow()),MainWindow,SLOT(newSubWindow()));
          //&MainWindow,SLOT(newSubWindow()));
          emit addSubwindow(1);

          What file/class we are in here? (i.e. what is this?). If this class doesn't have access to your MainWindow object, that you want to connect, this can't work. I doubt, that your object pointer is called/spelled MainWindow. And if it does, it would be very confusing.


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          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