简体   繁体   English

如何在Qt Designer中使用按钮更改QStackWidget页面索引?

[英]How can i change QStackWidget page index with button in Qt Designer?

I am currently working in Qt Designer and i am trying to make button change the index of QStackWidget with click signal. 我目前在Qt Designer中工作,并且尝试通过单击信号使按钮更改QStackWidget的索引。

I entered signal editor mode and connected Button to QStackWidget, This is what i got: 我进入信号编辑器模式,并将Button连接到QStackWidget,这是我得到的:

As you see in the picture, setCurrentIndex(int) is grayed out, If i choose any signal from QPushButton, there is nothing associated with changing page. 如您在图片中看到的, setCurrentIndex(int)呈灰色,如果我从QPushButton中选择任何信号,则与更改页面无关。

Sorted Question: 排序问题:

How can i change the page in QStackedWidget using a button? 如何使用按钮在QStackedWidget中更改页面? (In Qt Designer). (在Qt Designer中)。

That is not possible directly with Qt Designer, because QButton click signal doesn't send any index or argument, and setCurrentIndex(int) need an argument to chose change the index. Qt Designer无法直接实现这一点,因为QButton单击信号不会发送任何索引或参数,并且setCurrentIndex(int)需要一个参数来选择更改索引。
You have to do it using signal/slot in C++ code, or use an other widget like QSpinBox which emit a signal with an integer argument. 您必须使用C ++代码中的signal / slot来执行此操作,或者使用另一个QSpinBox小部件来发出带有整数参数的信号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM