當用Qt的qtcreator建純C/C++項目時,qt會調用一個控制台,類似windows下的console。預設狀態下是不顯示中文的,NND。Google了一圈無解。
求人不如求己啊!記得最初啟動qt的這個控制台時,qt提示沒有Xterm。也就是說Qt調用的控制台是Xterm,參照配置Xterm的兩篇文章:http://blog.sina.com.cn/s/blog_6a75ed3d0100p10b.html
http://tieba.baidu.com/p/1798593957
Xterm的設定檔在一個叫Xresources的檔案裡,首先切換到root,然後locate Xresources,看到檔案路徑在:/etc/X11/Xresources;
[root@localhost ~]# gedit /etc/X11/Xresources
開啟後,預設的配置內容是:
! This is the global resources file that is loaded when! all users log in, as well as for the login screen! Fix the Xft dpi to 96; this prevents tiny fonts! or HUGE fonts depending on the screen size.Xft.dpi: 96! hintstyle: medium means that (for Postscript fonts) we! position the stems for maximum constrast and consistency! but do not force the stems to integral widths. hintnone,! hintslight, and hintfull are the other possibilities.Xft.hintstyle: hintmediumXft.hinting: true
經過我驗證,在上面添加一句話就可以了:
xterm*faceName:Monospace:antialias=True:pixelsize=15
運行:[root@localhost ~]# xrdb /etc/X11/Xresources
使設定檔生效就可以讓qt的qtcreator_process_stub正常顯示中文了!
但是這個時候,跳出來的控制台太寬了很不美觀,添加這句設定寬和高:
xterm*geometry: 50x24
即寬為50,高為24.
為了保險起見,加了這句:
xterm*faceNameDoublesize:WenQuanYi Zen Hei:antialias=True:pixelsize=15
這是來設定字型的,用的系統的文泉驛,系統內建的哦!
總結:添加的配置語句有下面紅色三句,改好後一定要#xrdb /etc/X11/Xresources。
!font and locale
!xterm*locale: true
!xterm.utf8: true
!xterm*utf8Title: true
!xterm*fontMenu*fontdefault*Label: Default
xterm*geometry: 50x24
xterm*faceName:Monospace:antialias=True:pixelsize=15
!xterm*boldFont:Sans:style=Bold:pixelsize=13
xterm*faceNameDoublesize:WenQuanYi Zen Hei:antialias=True:pixelsize=15
!xterm*xftAntialias: true
!xterm.cjkWidth:true
!XTerm*preeditType: Root
帶!的表示屏蔽掉了,大家根據自己情況,如果需要的話再配置。
上張: