Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
QStackedWidget からウィジェットを削除した後、対応する位置に従ってウィジェットのインデックスを更新したいと考えています。おそらく、そのためにはループが必要です。どうすればいいですか。
1)ウィジェットが削除されると、シグナル-widgetRemoved(int index) が発行されます。
widgetRemoved(int index)
2)関数count()を使用することにより、ウィジェットの数を取得できます。
count()
これで、削除されたウィジェットのインデックスとウィジェットの総数がわかりました。これらの情報を使用して、関数を使用して他のウィジェットのインデックスを適宜設定しますsetCurrentIndex(int index)。
setCurrentIndex(int index)