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. Connect Designer Created Signal To Slot In Another Class
Forum Updated to NodeBB v4.3 + New Features

Connect Designer Created Signal To Slot In Another Class

Scheduled Pinned Locked Moved Solved General and Desktop
gui signals
5 Posts 2 Posters 448 Views 1 Watching
  • 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.
  • F Offline
    F Offline
    Frogs-Mulligan
    wrote on 11 Jul 2020, 15:12 last edited by
    #1

    My project has a Designer built gui. I need to connect a menu item signal to a slot in another class. I can find no way to do that using the signals and slots editor. I know I must be missing something, but can't figure out what it is. So far, the docs haven't helped.

    I thought of connecting the menu item slot to the other class slot, but don't how to go about it. Controller class in between, maybe?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 11 Jul 2020, 16:32 last edited by
      #2

      Hi
      So you have a QMenu in Mainwindow and what to connect that to some other class that is
      not MainWindow?

      F 1 Reply Last reply 11 Jul 2020, 17:09
      0
      • M mrjj
        11 Jul 2020, 16:32

        Hi
        So you have a QMenu in Mainwindow and what to connect that to some other class that is
        not MainWindow?

        F Offline
        F Offline
        Frogs-Mulligan
        wrote on 11 Jul 2020, 17:09 last edited by
        #3

        @mrjj Yes, exactly.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 11 Jul 2020, 17:13 last edited by
          #4

          Hi
          Im not sure you can do that with the signals and slot editor.
          So you have to do it from code when you create an instance of that other class.

          pseudo code

          Myclass* c= new MyClass;
          connect( ui->Action, Qction::triggered, c, MyClass::SomeSlot )
          
          1 Reply Last reply
          2
          • F Offline
            F Offline
            Frogs-Mulligan
            wrote on 11 Jul 2020, 19:21 last edited by
            #5

            Thank you.

            Here is the actual code that is working for me.

              CleoArea *cArea = new CleoArea;
               connect(ui->actionZoom_In, &QAction::triggered, cArea, &CleoArea::updateAll);
            

            I have verified that updateAll is being called by the signal slot mechanism. Unfortunately, updateAll does not itself function properly when the mouse cursor is not over the central widget, which is another problem.

            I will mark this thread as Solved and if need be, open a new one on the mouse cursor location issue.

            Thank you again. This forum is much appreciated.

            1 Reply Last reply
            2

            1/5

            11 Jul 2020, 15:12

            • Login

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