且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 QT 中访问父小部件指针

更新时间:2023-09-24 10:33:40

我会让你的子类发出一个信号 - 例如 'next' 和 'prev' - 然后在你的主窗口中连接这个信号来切换 QStackWidget 的当前小部件.

I would have your subclasses emit a signal - 'next' and 'prev' for example - and then connect this signal in your main window to switch the QStackWidget's current widget.

否则,您会以不必要的方式紧密耦合堆叠的小部件.

Otherwise, you're tightly coupling your stacked widgets in a way that is unnecessary.