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. QT Project crashes when attempting signal slot connect()
Qt 6.11 is out! See what's new in the release blog

QT Project crashes when attempting signal slot connect()

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 893 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.
  • S Offline
    S Offline
    SOrton
    wrote on last edited by
    #1

    Hi,

    Im struggling to find why my signal causes my program to completely crash.
    I am sending from a dialog to my main wondow (class->class)
    reciever header file:
    a4e8110b-7bda-490d-a8fc-99c7b4a0dee5-image.png
    Receiver (slot) function + function that creates the child dialog:
    4c361215-688a-4a16-8574-108faadb5902-image.png
    sender header file:
    52d5ea1f-a953-4292-8363-8eaa6b7e8303-image.png
    sender cpp file (including connect() func):
    440a3640-99f6-4929-826b-30f909f4cc0c-image.png

    Would greatly apreciate if anyone can figure this out.

    jsulmJ JonBJ 2 Replies Last reply
    0
    • S SOrton

      Hi,

      Im struggling to find why my signal causes my program to completely crash.
      I am sending from a dialog to my main wondow (class->class)
      reciever header file:
      a4e8110b-7bda-490d-a8fc-99c7b4a0dee5-image.png
      Receiver (slot) function + function that creates the child dialog:
      4c361215-688a-4a16-8574-108faadb5902-image.png
      sender header file:
      52d5ea1f-a953-4292-8363-8eaa6b7e8303-image.png
      sender cpp file (including connect() func):
      440a3640-99f6-4929-826b-30f909f4cc0c-image.png

      Would greatly apreciate if anyone can figure this out.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #3

      @SOrton
      It's a lot easier for people to reply if you paste your code as text not as screenshots.

      In AddDataDialog:

      MainWindow *test = new MainWindow;
      connect(..., test, ...);
      

      You are creating a brand new MainWindow here, in your dialog. This is conceptually wrong.

      If this were to work at all you would need the instance of MainWindow to pass as parameter. But don't try to do the connection from the dialog anyway. Do it from MainWindow. Either export a getter returning ui->btn_Exit or emit a new signal from AddDataDialog for the button being clicked/exiting and connect that. Either way connect() back in MainWindow. You wouldn't need a signal if you show the dialog modally, but maybe that's not your case.

      1 Reply Last reply
      2
      • S SOrton

        Hi,

        Im struggling to find why my signal causes my program to completely crash.
        I am sending from a dialog to my main wondow (class->class)
        reciever header file:
        a4e8110b-7bda-490d-a8fc-99c7b4a0dee5-image.png
        Receiver (slot) function + function that creates the child dialog:
        4c361215-688a-4a16-8574-108faadb5902-image.png
        sender header file:
        52d5ea1f-a953-4292-8363-8eaa6b7e8303-image.png
        sender cpp file (including connect() func):
        440a3640-99f6-4929-826b-30f909f4cc0c-image.png

        Would greatly apreciate if anyone can figure this out.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by jsulm
        #2

        @SOrton Please post code as text, not pictures!
        Where exactly (in which line) does it crash?

        Why does AddDataDialog create a new MainWindow instead of using the existing one?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • S SOrton

          Hi,

          Im struggling to find why my signal causes my program to completely crash.
          I am sending from a dialog to my main wondow (class->class)
          reciever header file:
          a4e8110b-7bda-490d-a8fc-99c7b4a0dee5-image.png
          Receiver (slot) function + function that creates the child dialog:
          4c361215-688a-4a16-8574-108faadb5902-image.png
          sender header file:
          52d5ea1f-a953-4292-8363-8eaa6b7e8303-image.png
          sender cpp file (including connect() func):
          440a3640-99f6-4929-826b-30f909f4cc0c-image.png

          Would greatly apreciate if anyone can figure this out.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #3

          @SOrton
          It's a lot easier for people to reply if you paste your code as text not as screenshots.

          In AddDataDialog:

          MainWindow *test = new MainWindow;
          connect(..., test, ...);
          

          You are creating a brand new MainWindow here, in your dialog. This is conceptually wrong.

          If this were to work at all you would need the instance of MainWindow to pass as parameter. But don't try to do the connection from the dialog anyway. Do it from MainWindow. Either export a getter returning ui->btn_Exit or emit a new signal from AddDataDialog for the button being clicked/exiting and connect that. Either way connect() back in MainWindow. You wouldn't need a signal if you show the dialog modally, but maybe that's not your case.

          1 Reply Last reply
          2

          • Login

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