Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. slots and signals question with embedded widgets.
Forum Updated to NodeBB v4.3 + New Features

slots and signals question with embedded widgets.

Scheduled Pinned Locked Moved Unsolved Qt for Python
4 Posts 3 Posters 373 Views 2 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.
  • M Offline
    M Offline
    mikeabuilder
    wrote on last edited by
    #1

    Noob-ish question. I'm having a problem making slots work when a widget is "embedded" in Qframe widget in the main window.

    The widget to embed
    In QtDesigner, I created the widget I want to embed, based on QFrame. It has a lot of controls, so I call it Control.

    I have a module where I define a class for Control.

    • I list itemuse uic.loadUI in it's init.
    • I also have callback functions defined in the class to respond to user inputs.
    • In QT designer, I linked these slots to signals from a push button and a checkbox.

    MAIN WINDOW
    In QT designer, I created a QFrame as a placeholder for the widget I want to "embed". I call it "target frame" I created a module where I define a class for main window, using uic.loadUI. In the init function, I import the class for Control, then create an instance of it. Then I set it's parent to be "target frame".

    This works for the display. When I run my application, I see the Control frame located where I expect it in the mainwindow UI. My problem is that when I push the pushbutton or check the checkbox, the callback function doesn't run.

    I tried building the COntrol frame into the mainwindow in Designer, and putting the callbachs in the mainwindow class. then they work. I have a lot of additional controls to add and I was hoping to not clutter up my main window class with them.

    Is there a right way to do this? I tried "promoting" in the UI, but I wasn't able to get how to make that work at all.

    jsulmJ 1 Reply Last reply
    0
    • M mikeabuilder

      Noob-ish question. I'm having a problem making slots work when a widget is "embedded" in Qframe widget in the main window.

      The widget to embed
      In QtDesigner, I created the widget I want to embed, based on QFrame. It has a lot of controls, so I call it Control.

      I have a module where I define a class for Control.

      • I list itemuse uic.loadUI in it's init.
      • I also have callback functions defined in the class to respond to user inputs.
      • In QT designer, I linked these slots to signals from a push button and a checkbox.

      MAIN WINDOW
      In QT designer, I created a QFrame as a placeholder for the widget I want to "embed". I call it "target frame" I created a module where I define a class for main window, using uic.loadUI. In the init function, I import the class for Control, then create an instance of it. Then I set it's parent to be "target frame".

      This works for the display. When I run my application, I see the Control frame located where I expect it in the mainwindow UI. My problem is that when I push the pushbutton or check the checkbox, the callback function doesn't run.

      I tried building the COntrol frame into the mainwindow in Designer, and putting the callbachs in the mainwindow class. then they work. I have a lot of additional controls to add and I was hoping to not clutter up my main window class with them.

      Is there a right way to do this? I tried "promoting" in the UI, but I wasn't able to get how to make that work at all.

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

      @mikeabuilder said in slots and signals question with embedded widgets.:

      My problem is that when I push the pushbutton or check the checkbox, the callback function doesn't run.

      For signal/slot connections it does not matter where you put the widget. So, if the slot is not called when you did something wrong, but without code we can only guess.

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

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mikeabuilder
        wrote on last edited by
        #3

        PEBCAC - I worked to make a simple repro case and it worked properly. Upon further investigation I found two copies of my widget.ui file (the result of reorging my files to simplify things!). Turns out I was adding slots to the file I was not calling with uic.loadUI. So issue solved. I'd delete the post if I knew how.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Don't ! Even if you think it's a silly error, you're not alone having fallen for that and your post might help somebody else in their investigation :-)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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