GTK+中文社区(gtk.awaysoft.com)

 找回密码
 马上加入

QQ登录

只需一步,快速开始

查看: 2340|回复: 4

Linux下编译gtk+报错

[复制链接]

该用户从未签到

发表于 2012-3-19 23:12:59 | 显示全部楼层 |阅读模式
用函数gtk_menu_item_set_use_underline设置快捷键时,使用Alt+下划线之后的字母实现。
当我在Visual Studio 2005中将代码写好,拷贝到Linux下,进行make时,出现了:
undefined reference to `gtk_menu_item_set_use_underline'错误,
前提:源程序在VS2005下编译成功,而且运行良好。
刚才在http://developer.gnome.org/gtk/2.24/GtkMenuItem.html上看到了这样一段话:



gtk_menu_item_get_use_underline ()

gboolean            gtk_menu_item_get_use_underline     (GtkMenuItem *menu_item);
Checks if an underline in the text indicates the next character should be used for the mnemonic accelerator key.

menu_item :
a GtkMenuItem

Returns :
TRUE if an embedded underline in the label indicates the mnemonic accelerator key.

Since 2.16我的是Fedora10,昨天刚采用在线安装的方法安装成功。
是不是这个和我的gtk+版本有关系?怎么查看我现在使用的gtk+的版本?如果是版本的问题,那么在VS2005下也应该报错才对,这个什么原因?怎么解决?
注释掉那行代码后,就可以make成功,也可以运行出结果。menuItem = gtk_menu_item_new_with_label ("_File");
gtk_menu_item_set_use_underline (GTK_MENU_ITEM(menuItem), TRUE);
就是第二行的错。

该用户从未签到

 楼主| 发表于 2012-3-27 00:12:07 | 显示全部楼层
这个问题大家没有遇到么?很是纳闷。
  • TA的每日心情
    奋斗
    2016-10-11 09:20
  • 签到天数: 271 天

    连续签到: 1 天

    [LV.8]以坛为家I

    发表于 2012-3-27 23:16:05 | 显示全部楼层
    Since 2.16

    Fedora 10下的gtk是哪个版本的?

    该用户从未签到

     楼主| 发表于 2012-3-29 23:33:12 | 显示全部楼层
    原来是版本的问题
    http://developer.gnome.org/gtk/2.24/GtkMenuItem.html上面显示的是这样的:
    gtk_menu_item_set_use_underline ()
    void                gtk_menu_item_set_use_underline     (GtkMenuItem *menu_item,
                                                             gboolean setting);If true, an underline in the text indicates the next character should be used for the mnemonic accelerator key.

    menu_item :
    a GtkMenuItem  
    setting :
    TRUE if underlines in the text indicate mnemonics

    Since 2.16

    在Windows下是2.24.8,在线安装的是2.14.7,版本落后一点。不知道有什么替代的函数么?

    该用户从未签到

     楼主| 发表于 2012-3-30 20:31:35 | 显示全部楼层
    今天在看gtk+API手册的时候发现了一个函数:gtk_menu_item_new_with_mnemonic ()
    GtkWidget* gtk_menu_item_new_with_mnemonic (const gchar *label);
    Creates a new GtkMenuItem containing a label. The label will be created using gtk_label_new_with_mnemonic(), so underscores in label indicate the mnemonic for the menu item.


    label : The text of the button, with an underscore in front of the mnemonic character   
    Returns : a new GtkMenuItem   
    这个函数解决了那个问题。
    *滑块验证:
    您需要登录后才可以回帖 登录 | 马上加入

    本版积分规则

    申请友链|Archiver|小黑屋|手机版|GTK+中文社区 ( 粤ICP备13080851号 )

    我要啦免费统计

    GMT+8, 2024-4-30 01:09 , Processed in 0.021245 second(s), 7 queries , Redis On.

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表