gpt4 book ai didi

c - 传递 GtkWidget 参数

转载 作者:太空宇宙 更新时间:2023-11-04 10:43:31 25 4
gpt4 key购买 nike

我有一个函数连接到 gtk 中组合框的“已更改”信号,它又调用另一个函数 read_button_config。

read_button_config 采用主窗口、一个组合框和一个我没有全局声明的 vcontainer 作为参数

哪种方式更适合传递这些参数:- 全局声明参数- 将参数作为结构传递给第一个函数,并将结构成员传递给 read_button_config 函数?

请告诉我为什么你认为哪个更好,我想知道什么是对 future 发展更好的方式

最佳答案

Which way is better for passing these parameters: - declaring the parameters globally - passing the parameters as a struct to the first function, and passing the struct members to the read_button_config function?

后者是首选方式;毕竟,这就是 user_data 参数向函数发出信号的目的。
全局声明它们不是。相反,使用 user_data惯用的。这有点困难,因为您必须自己管理 user_data 的内存,但是使用 user_data 可以使您的代码模块更加独立。你需要决定你想做什么。 – 和实验室

关于c - 传递 GtkWidget 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34055179/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com