slots and signals question with embedded widgets.
-
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.
-
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.
@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.
-
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.
-
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 :-)