-2

I want to use btn1 to send a signal to the slot function of deviceTypeSelect, but btn1 can only be associated with QStackedWidget. enter image description here

enter image description here

Alex
  • 150
  • 9

1 Answers1

1

There are two problems.

The first is conceptual: Designer cannot know anything about custom slots that are going to be implemented in a promoted widget, and it even should not. The connection to those slots can only be achieved programmatically, and that's for good reasons: Designer cannot "inspect" (nor it should) the source of the files that will be promoted, and it's also completely possible that one would promote a widget and use different classes with the same design files.

The other problem is technical: the "pages" of multipage widgets like QStackedWidget or QTabWidget cannot be used as signal targets on Designer. I don't know if it's just a missing feature or it's by design (knowing how multipage widget plugins are dealt with I wouldn't bet about the it), but unfortunately it really is not possible.
If you want to connect to standard QWidget slots (setEnabled() etc.), set a dummy boxed layout on the page, and add another QWidget in it, but if you use custom slots, as explained before, those must be manually connected from your code.

musicamante
  • 41,230
  • 6
  • 33
  • 58
  • Thanks for comment ,So I can only promote QStackedWidget, and then customize the slot in it to associate the signal of btn1. – Alex Dec 03 '20 at 09:22
  • That's up to you, but since custom slots can only be connected programmatically there's no much difference, it just depends on what that slot is going to do: if it does something on *that page* only, promoting the page will suffice, but if its interaction is in the common scope of the stacked widget, promote that one instead. – musicamante Dec 03 '20 at 09:32