科学网

 找回密码
  注册
科学网 标签 gui

tag 标签: gui

相关帖子

版块 作者 回复/查看 最后发表

没有相关内容

相关日志

matlab GUI 崩溃的启示
cheg37 2019-10-28 17:08
本人电脑装载了一个集成显卡,一个独立显卡。 一天切换显卡后,出现了打开GUI,MATLAB就瞬间崩溃的现象。 经过上网查询,大致知道了是由于OPENGL的渲染问题造成, 发现matlab 里进行图形渲染的OpenGL实现,有三种方式:硬件加速(hardware-accelerated),基本硬件加速(basic hardware-accelerated)以及软件实现(software)。 首先想到的就是把渲染方式调回软件实现的方式。结果,出现:在关闭集成显卡的模式下,GUI能正常运行。但是在打开集成显卡时,运行GUI,matlab瞬间崩溃,并且,输入:opengl info,matlab也瞬间崩溃。似乎,opengl不能碰。 软件实现模式似乎并不友好! 于是,将渲染模式调为基本硬件加速(basic hardware-accelerated)模式,结果,两个显卡自由切换,GUI再也不会造成MATLAB崩溃的现象了。 总结,软件实现的方式感觉是跟硬件没有关系的最保险方式,其实,这种模式跟硬件也息息相关,并且对集成显卡不能很好的识别! 希望对大家能有帮助!
个人分类: 个人心得|4068 次阅读|2 个评论
Matlab: stop running and close GUI
haibaraxx 2016-8-21 03:26
stop running the program: control+C (not command+C even using mac) close GUI: type in quit command
个人分类: Matlab|2422 次阅读|0 个评论
QT GUI 初探
zhanghouxing 2016-7-24 23:29
周末花点时间折腾QT GUI的东西,基本东西掌握得差不多了,现在点总结。 (1)第一步,我们新建一个主窗口,然后添加三个文本框,计算两个数据之和: 在UI deigner中拖入文本框,然后加入两个按钮,我们右键button1,选择-转入槽,关于基本概念,我就不解释了,进入到click事件响应函数里面: 然后,即可实现两个数据之和,并显示在文本3中。这里,为了理解Qt中信号与槽的机制,我做了一个的测试,我首先添加button Connect,然后再click事件响应函数中添加: connect( this - ui - add , SIGNAL (clicked()), this , SLOT (myslot1())); 其中add即Button1,myslot函数即上面函数中的内容,这样打开界面,先输入前面两个数,然后点击connect,最后点Button1即可。注意,此connet函数不能放在MainWindow的构造函数,否则this-ui-add无效,我现在的理解是,在建立新建窗口时,便首先进入窗口的构造函数,然而此时窗口的组成部分如button,editText并未实例化,所以this-ui-add无效显示NULL;当然这种方法,完全没有必要,有点画蛇添加的意思,主要是为学习。 (2)建立菜单和工具 如上图所示,我们建立三个主菜单和四个工具,建立菜单方法简单,直接在文本框输入菜单名字,并双击即可,点击菜单,可以建立多个Action,如下图所示: 相应地,我们可以拖到Action Editor下面的刚刚建立的Action到工具栏,构成工具,如下图: (3)为Action建立响应函数 右键上面建立的Action,转入槽,然后进入函数,这里我们编写了一个打开文本文件,并显示到MainWindow上 文本框上,修改文本框内容,点击保存,可以保持到打开的文本文件中,代码如下: 演示: (4)最后,我们要建立多窗口,并实现数据的传递 首先我们添加Dialog类,方法就是右键项目文件,选择添加新文件,选择QT设计师界面类,如下: 这时候在工程文件中,就会多了三个,dialog1.h和dialog1.cpp,dialog1.ui,打开ui文件便可以对dialog进行编辑,我们建立如下的Dialog: 然后我们在主菜单忠的编辑菜单下Action列表中,选择New,右键选择转入槽,输入如下代码: void MainWindow ::on_NewWindow_triggered(){ dialog1 .show(); // dialog1.showText(TextEdit); dialog1 .exec();} 注意,在调用dialog1.show函数时,首先要引入include dialog1.h,然后新建dialog1,可以MainWindow的头文件实现,也可以在上面的函数中实现,即: Dialog1 dialog1 ; //(前面是类名,后面是实例化变量) (5) 主窗口与子窗口数据传递。 功能描述,在主窗口中打开文本文件显示之后,点击按钮PushtoDialog,主窗口txt显示在dialog窗口中,相反的功能也能实现。 首先,我们要建立主窗口的信号函数,然后将文本框中内容传入进去: void MainWindow ::on_pushButton_2_clicked(){ emit mysignalShow( TextEdit );} 然后,建立dialog1中对应的槽函数, 一定记住,信号函数和槽函数格式必须一样 ,即: void Dialog1 ::showText( QString string){ this - ui - textEdit -setText(string); //写内容 } 最后,连接信号与槽: 用同样的方法,建立Dialog1中信号函数: void Dialog1 ::on_pushMain_clicked(){ txtShowinMain = this - ui - textEdit -toPlainText(); emit textShowInMain( txtShowinMain ); } 然后建立,MainWindow中的SLOT函数: void MainWindow ::MaintxtShow( QString string){ this - ui - textEdit_2 -setText(string);} 最后连接(也在MainWindow的构造函数中连接,只要dialog已经在头文件新建,这里就可以连接了): 搞定:
个人分类: Qt|4667 次阅读|0 个评论
Matlab: 学习GUI(修改窗口左上角图标而不warning)
sanshiphy 2015-4-29 19:04
网上常用的方法: if ~isdeployed newIcon=javax.swing.ImageIcon('.\pic\iap.jpg'); else newIcon=javax.swing.ImageIcon('iap.jpg'); end jFrame = get(hObject,'javaframe'); jFrame.setFigureIcon(newIcon); 运行后warning: Warning: figure JavaFrame property will be obsoleted in a future release. For more information see the JavaFrame resource on the MathWorks Web site. 新方法 ( http://www.mathworks.com/matlabcentral/answers/7313-change-guide-icon ): if ~isdeployed newIcon=javax.swing.ImageIcon('.\pic\iap.jpg'); else newIcon=javax.swing.ImageIcon('iap.jpg'); end jFrame = get( handle (hObject),'javaframe'); jFrame.setFigureIcon(newIcon);
个人分类: 技术备忘录|7913 次阅读|0 个评论
Matlab:学习GUI(Reference to non-existent field的问题)
sanshiphy 2015-3-20 14:51
有时我们在程序中自定义一个函数,对 handles 数据进行修改,然后 guidata 保存,可是运行后程序提示:“ Reference to non-existent field…. ”之类的错误,这是怎么回事呢?该错误以下例说明: 如图,建立一个文本框,在 OpeningFcn 函数中设定显示值为 1. function untitled1_OpeningFcn(hObject, eventdata, handles,varargin) handles.output =hObject; initialize(hObject,handles); % 设定文本框显示值handles.x的值为1 set(handles.edit1,handles.x); % 文本框显示为1 % Updatehandles structure guidata(hObject,handles); function initialize(fig_handle,handles) handles.x=1; guidata(fig_handle,handles); 运行后提示错误: “ Reference to non-existent field ‘ x ’” ,提示说找不到定义的x.很明显initialize函数并没有把handles.x传递给全局变量handles. handles虽然是全局变量,但还没有全局到所有子函数都是可见的。像callback这些关于component的函数,handles是可见的。但是 ,用户自定义的函数,handles是不可见的,用户不能自定义子函数中修改handles的值 。
个人分类: 技术备忘录|21387 次阅读|0 个评论
Matlab: 学习GUI (使用GUIDE时需注意的几个问题)
sanshiphy 2015-3-6 14:22
在博文《 Matlab :学习 GUI (一个简单的例子)》( http://blog.sciencenet.cn/blog-200199-870822.html) 中 介绍的方法是完全用代码来建立一个 GUI ,实际上 Matlab本身有 一个设计 GUI 的交互系统—— GUIDE ,用户可以使用该系统更方便的建立自己的 GUI. 本文将介绍使用 GUIDE 时常常遇到的几个问题。 本文将通过一个简单的例子来说明问题,读者朋友们可以边看边操作。在 command line 输入 guide 回车,打开 Layout Editor. 建立一个空白的模板( Blank GUI ),建立一个 push button ,将“ String ”改为“ Close ”, save 并将文件名命名为 test ,如下图: save 后, Matlab 会生成两个文件 test.M 和 test.fig ,打开 test.M ,如下: function varargout = test(varargin) % Begin initializationcode - DO NOT EDIT gui_Singleton = 1; gui_State = struct( 'gui_Name' , mfilename, ... 'gui_Singleton' , gui_Singleton, ... 'gui_OpeningFcn' , @test_OpeningFcn, ... 'gui_OutputFcn' , @test_OutputFcn, ... 'gui_LayoutFcn' , ); if nargin ischar(varargin{1}) gui_State.gui_Callback =str2func(varargin{1}); end if nargout =gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code- DO NOT EDIT % --- Executes justbefore test is made visible. function test_ OpeningFcn (hObject,eventdata, handles, varargin) handles.output = hObject; guidata(hObject, handles); % --- Outputs from thisfunction are returned to the command line. function varargout = test_ OutputFcn (hObject,eventdata, handles) varargout{1} = handles.output; % --- Executes on buttonpress in pushbutton1. function pushbutton1_ Callback (hObject,eventdata, handles) 生成的 M 文件的结构主要由三个子函数构成: _OpeningFcn ,这个函数是在 GUI 界面出现以前 Matlab 在后台运行的, GUI 设计者可以在这个函数内完成数据初始化设置、 GUI 的界面的控制和调整等工作。 _OutputFcn 函数是 M 文件最后运行的函数,主要是为了输出运行结果。 _Callback 函数用于控制 component 的触发行为,比如说用户按下界面的按钮后,该按钮应该执行什么命令。我们这个例子设计的是按下“ Close ”按钮后, GUI 界面关闭,因此需要在 function pushbutton1_ Callback (hObject, eventdata, handles) 后面加上: delete(handles.figure1); 下面我们开始借助这个简单的例子,讲一讲新手在应用 GUIDE 时常见的三个问题: 问题一: figure Name 和 figure tag 弄混了。 Figure Name 指的是 M 文件和 Fig 文件的 name ,即本例中的 test. Tag 指的是设计 GUI 界面时为每个 component 所指定的标签,也是程序中唯一的可以识别 component 的名字, GUI 的面板也是一个 component ,有自己的 tag ,即本例中默认的 figure1. 弄混 figure tag 和 figure name 的例子如下: 错误代码: function pushbutton1_Callback(hObject, eventdata, handles) delete(handles.test); 当运行错误代码时, Matlab 会提示找不到 handles 中的 test 变量,因为 handles 只是存储 component 的句柄,每个句柄是以 tag 来命名的: ??? Reference to non-existentfield 'test'. Error in ==testpushbutton1_Callback at 81 delete(handles.test); 问题二: uiwait 在逻辑上与 uiresume 不配对。 还是上面的例子,如果再增加一个功能,等用户按下“ Close ”按钮后,在屏幕输出“ OK ”,否则不输出。为实现该功能,在 test_ OpeningFcn 的 guidata 语句后增加: % UIWAIT makes test waitfor user response (see UIRESUME) uiwait(handles.figure1); 在 test_OutputFcn 的 varargout{1} 语句后添加: delete(handles.figure1); 将 pushbutton1_Callback 中的 delete(handles.figure1) 删除,并添加: disp('OK'); uiresume(handles.figure1); 运行后,用户点击“ Close ”按钮,一切正常。 可是,当用户不点击“ Close ”而是直接关闭窗口时,程序提示 OutputFcn 输出错误: 出现该错误的原因是:当用户直接关闭窗口时,所有在内存中的变量都被清楚,程序在执行到 OutputFcn 是已没有变量可以赋值给结构变量 varargout{1} 了。为了改正该错误,需要添加 _CloseRequestFcn 函数: % Executes when userattempts to close figure1. function figure1_CloseRequestFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future versionof MATLAB % handles structure with handles and user data (seeGUIDATA) if isequal(get(hObject, 'waitstatus' ), 'waiting' ) % TheGUI is still in UIWAIT, us UIRESUME uiresume(hObject); else % TheGUI is no longer waiting, just close it delete(hObject); end 可是,如果直接将上述代码复制到 test.m 文件中,保存,运行,关闭窗口时,同样会出现上述 OutputFcn 输出错误,这个就涉及到下面第三个问题。 问题三: Layout Editor 的设置和 M 文件不同步。 为解决上述问题,可打开 figure1 的 Property Inspector, 注意到 CloseRequestFcn 一栏,显示的是 closereq ,点击以下旁边的图片,变为: 这说明两者已经同步,此时可以放心的运行程序了。
个人分类: 技术备忘录|19830 次阅读|0 个评论
Matlab:学习GUI(一个简单的例子)
sanshiphy 2015-2-28 21:43
GUI是graphical user interface的简称,说白了就是我们常见的对话框。 下面是Matlab提供的一个简单例子,博主加上了自己的注释,供参考。 function hpopup=simple_gui2 % SIMPLE_GUI2 Select a data set from the pop-up menu, then % click one of the plot-type push buttons. Clicking the button % plots the selected data in the axes. % Initialize and hide the GUI as it is being constructed. % 生成图形面板,'visible'('on'\'off')是/否显示面板,'position' % 定义面板在显示屏上的位置(left,距离屏幕左边界的距离;bottom,距离屏幕下边界的距离) % 以及面板的大小(width,面板宽;height,面板高,不包括title bar, menu bar, tool bars, and outer edges) % The left and bottom elements can be negative on systems that have more % than one monitor. 缺省单位是pixels. f = figure('Visible','off','Position', ); %%%%%%%%%与figure相关的控制语句%%%%%%%%%%%%%% % Assign the GUI a name to appear in the window title. set(f,'Name','Simple GUI') % Move the GUI to the center of the screen. movegui(f,'center') % Make the GUI visible. set(f,'Visible','on'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Construct the components. % 利用uicontrol添加push button. 'Style',添加对象类型,还可添加pop-up menu,static text等类型. % 'String'('Text'),push button 上要显示的文字. 'position'同figure. % 'Callback',当用户按下button或选择pop-up menu时,Matlab执行的函数. hsurf = uicontrol('Style','pushbutton',... 'String','Surf','Position', ,'Callback',{@surfbutton_Callback}); hmesh = uicontrol('Style','pushbutton',... 'String','Mesh','Position', ,'Callback',{@meshbutton_Callback}); hcontour = uicontrol('Style','pushbutton',... 'String','Contour','Position', ,'Callback',{@contourbutton_Callback}); hpopup = uicontrol('Style','popupmenu',... 'String',{'Peaks','Membrane','Sinc'},... 'Position', ,'Callback',{@popup_menu_Callback}); htext = uicontrol('Style','text','String','Select Data',... 'Position', ); % 利用uicontrol添加static text ha = axes('Units','pixels','Position', ); % 添加坐标轴以显示输出结果,注意用'Units'指定Position的单位是'pixels',以与其它对象保持一致. align( ,'Center','None'); % 水平中心对齐push button、pop-up mesh以及static text,垂直方向不变动 % align(HandleList,'HorizontalAlignment','VerticalAlignment') % Initialize the GUI. % Change units to normalized so components resize automatically. set( ,'Units','normalized'); % Make the GUI behave properly when it is resized by changing the component % and figure units to normalized. This causes the components to resize when the GUI is resized. % Normalized units map the lower-left corner of the figure window to (0,0) % and the upper-right corner to (1.0, 1.0). % 将面板放大的时候,各对象(axes\buttons\pop-up menu\static text等)同比例放大 % Generate the data to plot. peaks_data = peaks(35); membrane_data = membrane; = meshgrid(-8:.5:8); r = sqrt(x.^2+y.^2) + eps; sinc_data = sin(r)./r; % Create a plot in the axes. current_data = peaks_data; surf(current_data); % Pop-up menu callback. Read the pop-up menu Value property to % determine which item is currently displayed and make it the % current data. This callback automatically has access to % current_data because this function is nested at a lower level. % 当用户触发popup menu时,句柄hpopup的值传给source % str=get(source, 'String') str是3*1的cell,即pop-up menu的string{'Peaks','Membrane','Sinc'} % val = get(source,'Value') val的值记录了用户触发了那个按钮,1对应'peaks',2对应的是'Membrane',3对应的是'Sinc' function popup_menu_Callback(source,eventdata) % Determine the selected data set. str = get(source, 'String'); val = get(source,'Value'); % Set current data to the selected data set. switch str{val}; case 'Peaks' % User selects Peaks. current_data = peaks_data; case 'Membrane' % User selects Membrane. current_data = membrane_data; case 'Sinc' % User selects Sinc. current_data = sinc_data; end end % Push button callbacks. Each callback plots current_data in the % specified plot type. function surfbutton_Callback(source,eventdata) % Display surf plot of the currently selected data. surf(current_data); end function meshbutton_Callback(source,eventdata) % Display mesh plot of the currently selected data. mesh(current_data); end function contourbutton_Callback(source,eventdata) % Display contour plot of the currently selected data. contour(current_data); end end
个人分类: 技术备忘录|10637 次阅读|0 个评论
perl GUI TK
zoubinbin100 2014-3-24 16:52
perl在分析生物信息数据时十分方便,但是在数据可视化上就比较困难,尤其是想开发一个GUI。目前也有很多模块能开发GUI,Tk是其中的一个,但是比起Matlab,VB之类的就显得很吃力。目前很想用perl开发一个生物信息软件处理Sanger sequence(abi),功能包括序列拼接,杂合碱基的识别,SNP识别,突变识别。底层perl代码基本已经实现,但是在软件图形化上却遇到了十分大的问题,甚至想过先用perl处理abi文件,然后再用VB开发GUI显示结果,其实Java挺合适的开发生物信息的GUI,因为BioJava功能十分强大,个人对Java不是十分熟悉,另外python也是个十分不错的选择,有很多生物信息软件都是python开发。 下面列出Tk的参考网址,以便以后开发GUI使用。 IBM: https://www.ibm.com/developerworks/cn/aix/library/au-perltkmodule/ Mastering Perl Tk: http://docstore.mik.ua/orelly/perl3/tk/
个人分类: Perl|1180 次阅读|0 个评论
第一次用MATLAB实现GUI有感
热度 4 feike0220 2013-5-10 00:26
导师让我用matlab研究在开采沉陷中的应用,我听着编程这个字眼就犯怵。 二话不说,我先去学校图书馆借了两本关于matlab的教程,一本中文的,一本英文原版的,鉴于着急入手,先把中文的用了两个星期学了一遍。之后的一周就是学习开采沉陷的理论,选择合适的函数模型,进行建模。 沉陷预测主要包括预测和参数预计,我主要目的是用matlab实现函数模型的可视化。我想利用电脑窗口可视化那样的效果,在菜单中进行各种操作。于是,我仔细学习了matlab中的GUI(graphical user interface) 的创建与应用那一部分,开始按照自己的构想去实现matlab在沉陷预计中的应用。 经过不懈的努力,我终于实现了。此时此刻,我怀着一颗喜悦的心,与读者分享一下成功的苦与乐: 痛苦的是,对于一个新事物,特别是没有接触过的事物,刚开始总是遇到这样那样的问题,单单针对每个调用的小函数的编译过程就得反复的调试、调试、再调试。每每调试成功一个小函数心中洋溢着喜悦之情,特别是最后函数的调用,的确,对于我个人来说是个瓶颈问题,因为我的设想根本不知道怎么去实现,查资料,翻文献,上网等等,经历了三天才把函数的调用给整明白。可想而知,连续一天半都在失败中告终,特别是最后一天的后半天,都有放弃的念头,仔细一想,爱迪生发明电灯泡还一千零一次实验呢,我这才改动几十次而已。我反复修改程序、修改函数、修改参数等等,反反复复,终于在刚刚实现了。 对于我来说,这就是一个小小的成功,仅以此份快乐、喜悦与读者分享,愿你们也能遇到困难、挫折坚持下去,特别是科研工作,认为能实现的的一定要坚持到底,到最后总会成功的。
个人分类: 科研笔记|4505 次阅读|7 个评论
[转载]bioperl 的GUI 安装法
hongenhugo 2012-4-26 22:37
安装了好几次,这次终于成功了。 1) Start the Perl Package Manager GUI from the Start menu. 2) Go to Edit Preferences and click the Repositories tab. Add a new repository for each of the following (note the difference based on the perl version). NOTE - The DB_File installed with ActivePerl 5.10 and above is a stub (i.e. it does not work). The Trouchelle database below has a working DB_File. Repositories to add Name perl 5.8 perl 5.10 BioPerl-Regular Releases http://bioperl.org/DIST http://bioperl.org/DIST BioPerl-Release Candidates http://bioperl.org/DIST/RC http://bioperl.org/DIST/RC Kobes http://theoryx5.uwinnipeg.ca/ppms http://cpan.uwinnipeg.ca/PPMPackages/10xx/ Bribes http://www.Bribes.org/perl/ppm http://www.Bribes.org/perl/ppm Trouchelle http://trouchelle.com/ppm http://trouchelle.com/ppm10 tcool http://ppm.tcool.org/archives/ NA 3) Select View All Packages . 4) In the search box type bioperl. (在英文输入状态下输入,不要急于按enter键) 5) Right click the latest version of Bioperl available and choose install. (Note for users of previous Bioperl releases: you should not have to use the Bundle-BioPerl package anymore.) 5a) From bioperl 1.5.2 onward, all 'optional' pre-requisites will be marked for installation. If you see that some of them complain about needing a command-line installation (eg. XML::SAX::ExpatXS), and you want those particular pre-requisites, stop now (skip step 6) and see the 'Command-line Installation' section. 6) Click the green arrow (Run marked actions) to complete the installation.
个人分类: BioPerl|2524 次阅读|0 个评论
[转载]QT程序运行过长(or太忙)导致主界面假死,可考虑processEvents
chuangma2006 2012-4-14 07:26
void QCoreApplication:: processEvents ( QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents ) Processes all pending events for the calling thread according to the specified flags until there are no more events to process. You can call this function occasionally when your program is busy performing a long operation (e.g. copying a file). In event you are r unning a local loop which calls this function continuously , without an event loop, the DeferredDelete events will not be processed. This can affect the behaviour of widgets, e.g. QToolTip , that rely on DeferredDelete events to function properly. An alternative would be to call sendPostedEvents() from within that local loop. Calling this function processes events only for the calling thread. zz: http://doc.qt.nokia.com/4.7-snapshot/qcoreapplication.html#processEvents
个人分类: QT|7910 次阅读|0 个评论
[转载]Building Qt Static/Dynamic and Making it Small with complier
chuangma2006 2012-4-8 08:49
Building Qt Static (and Dynamic) and Making it Small with GCC, Microsoft Visual Studio, and the Intel Compiler This article will show you how to build Qt, the popular C++ framework from Nokia, so that it is both small and, if you prefer, available for static linking . Your Qt applications will be smaller, possibly faster, and can be distributable as a single executable. Also answered: How small can Intel’s C++ compiler make a large library? How does Microsoft fare? Three compilers (settings tuned for small file output) and their resulting code size is compared. A nice table of contents so that you can see what you’re getting into: * optional Download the latest Qt source code and put it in its own directory. *Modify the compiler flags for use when building Qt. Open a command-line window for your compiler. Configure. Compile. *If you want to use static linking, modify your Qt project. A few things to keep in mind before we get started: Before getting started, you may wish to install a separate compiler.The full Qt SDK comes with G++3 as of this writing (G++ is the C++ compiler that comes with GCC). It works, but G++4 generates better code. I recommend the TDM release . Microsoft Visual Studio Intel’s compiler are also very capable. This article covers them all. G++ and the Intel compiler are compatible. Either compiler can link to libraries built with the other compiler. Microsoft’s C++ compiler is incompatible with the other two, so if you build Qt with it, you are stuck with Microsoft’s compiler for the whole project. This isn’t necessarily bad. Visual C++ is a fine compiler, and finishes compiling Qt noticeably faster than the other two. GCC is available free of charge, source code included. Microsoft’s compiler is available for free in their “ Express edition “. It is more or less fully functional. Intel’s compiler, however, is only available free of charge on the Linux platform, and even then only for non-commercial software development. That said, it is widely thought of as producing the fastest code. With that out of the way, let’s begin: Download the latest Qt source code and put it in its own directory. You can get the entire SDK or just the source code . Either way, each compilation should be in a separate folder. * Modify the compiler flags for use when building Qt. You’ll be changing one line of the file “make.conf” in the “mkspecs” folder. If Qt in the “C:\Qt” folder, for example, then the file is “C:\Qt\mkspecs\ COMPILER \make.conf”, where COMPILERis : “ win32-g++ ” for GCC “ win32-icc ” for the Intel compiler “ win32-msvc2008 ” for the Microsoft compiler (replace 2008 with the year of release).In all three cases, you will edit the line: “ QMAKE_CFLAGS_RELEASE = “, changing the contents after the equals sign to the following: For GCC: -Os -momit-leaf-frame-pointer For ICC: -Os -Oy For VC++: -O1 -Og -GL -MD For example, my ICC line shows: “ QMAKE_CFLAGS_RELEASE = -Os -Oy ” You may wish to add other optimizing flags as well. See your compiler’s documentation. Open a command-line window appropriate for your compiler . GCC: Open the command prompt (Start – Run – “cmd”), then run “mingwvars.bat”. For example, if GCC is installed in “c:\MinGW”, then enter the command: “ c:\MinGW\mingwvars.bat “ Microsoft Visual Studio : Look for the “Visual Studio 2008 Command Prompt” entry in your start menu. It is usually found under “Programs\Microsoft Visual Studio 200 X \Visual Studio Tools\”. The Express versions should be similar. Alternatively, search your hard drive for “vcvarsall.bat” and from that folder, run “ vcvarsall.bat x86 ” from the command line. Intel compiler : Similar to Visual Studio, an icon is provided in your start menu, usually in: “Programs\Intel(R) Software Development Tools\Intel(R) C++ Compiler x.y.z “. Alternatively, find iclvars.bat and from that folder, run “ iclvars.bat ia32 “ Configure Qt. Change to the Qt folder. For example, type cd C:\Qt\4.6.3-msv c if you unzipped Qt to C:\Qt\4.6.3-msvc.This folder should have configure.exe within. Run the following long command: configure -release -nomake examples -nomake demos -no-exceptions -no-rtti -no-qt3support -no-scripttools -no-openssl -no-opengl -no-webkit -no-phonon -no-style-motif -no-style-cde -no-style-cleanlooks -no-style-plastique -no-sql-sqlite Add “ -platform win32-??? ” for your compiler. Replace “???” with the name of your compiler, same as in step 2. You can also look for your compiler’s name in the Qt\mkspecs folder. For example, a Microsoft Visual Studio 2008 user would use “ -platformwin32-msvc2008 “. Add “ -static ” if you are compiling for static linking (libraries included in your .exe rather than as separate files. This mostly applies to qtcore4.dll and qtgui4.dll ) Add any static functionality your application needs., if you are compiling static For example, -qt-libjpeg -qt-zlib -qt-libpng for JPEG image, ZIP compression, and PNG (which also needs zlib) respectively. See How to Statically Link Qt4 . Remove “ -no-exceptions -no-stl -no-rtti ” if you need those C++ features. Note that with -no-stl , you are still able to use the ST L, but Qt will not have built-in convenience functions to, for example, set a QVector equal to a C++ vector. That is, you will have to do so manually. Replace “ -release ” with “ -debug-and-release ” if this will be your debug install, too. Do not use -static . The remaining “ -no- foo ” options disable various features. See the output of “ configure –help ” for documentation. You can write this to a file with “ configure –help options.txt “. Compile Qt . After step 4, you will be informed of which command starts the actual compile (usually mingw32-make or nmake ). (static only) Configure your project for use of the static library. It’s the size that counts and how you use it. When working towards making Qt (and therefore your projects) small, it is important to have some idea of what each compiler can do. I will compare the sizes of QtCore4.dll (core Qt functionality) and QtGui4.dll (Graphical interface libraries and operating system interface). These two files that are fairly representative of size scaling among Qt libraries, and also happen to be the two most common files needed by Qt applications. Interpretation: ICC’s code size is about the same as GCC’s unoptimized. The sum of both file’s sizes is 11.38MB on both compilers. With appropriate settings, GCC’s compiled Qt code size drops more than 40%, from 11.38MB to only 6.63MB combined. Microsoft Visual C++ handily beats the other compilers, with a library size less than half of ICC’s and about 15% smaller than GCC’s best effort.( Edit : Arik notes that this compilation is still dependent on Microsoft’s msvcrt XX .dll . See his comment below regarding how to eliminate this dependency. This may change the size of your application). Additionally, Microsoft’s compiler finished the job in about 1/5 the time of ICC and about 1/3 the time of GCC Optimized. I actually ran it twice because I thought it may have aborted without error, because the time difference was so substantial. Update : I’ve compiled CNB ImageGuide to provide a real application size example. Using G++, executable size is 5.8MB. Using Microsoft C++ 2008 and Arik’s suggestion, it is 3.56MB, or about a 60% difference. I’d like to welcome theories as to why the difference is so substantial. However : This does not take into account the performance of the resulting libraries , with Intel likely taking the lead. ICC is designed for absolute performance, not small code size. MSVC is not available on most platforms supported by Qt. The author is far more familiar with the compiler flags for G++ than for the other two compilers. It is possible that a particular combination of options will significantly change the results. I hope this has been helpful and informative. Communicate any feedback, good or bad, in the comments section. Repeatability Everyone is welcome to try to repeat, improve upon, or dispute my results. The settings used follow. Intel Compiler 11 cflags : -Os -Oy Qt configuration : -release -qt-libjpeg -qt-zlib -qt-libpng -nomake examples -nomake demos -no-exceptions -no-stl -no-rtti -no-qt3support -no-scripttools -no-openssl -no-opengl -no-webkit -no-phonon -no-style-motif -no-style-cde -no-style-cleanlooks -no-style-plastique -no-sql-sqlite -platform win32-icc Microsoft Visual C++ 2008 cflags : -O1 -GL -MD Qt configuration : -release -qt-libjpeg -qt-zlib -qt-libpng -nomake examples -nomake demos -no-exceptions -no-stl -no-rtti -no-qt3support -no-scripttools -no-openssl -no-opengl -no-webkit -no-phonon -no-style-motif -no-style-cde -no-style-cleanlooks -no-style-plastique -no-sql-sqlite -platform win32-msvc2008 GCC 4.4.1 default (TDM release 2) cflags : -O2 Qt configuration : -release -nomake examples -nomake demos -platform win32-g++ GCC 4.4.1 Optimized cflags : -Os -mpreferred-stack-boundary=2 -finline-small-functions -momit-leaf-frame-pointer Qt configuration : -release -qt-libjpeg -qt-zlib -qt-libpng -nomake examples -nomake demos -no-exceptions -no-stl -no-rtti -no-qt3support -no-scripttools -no-openssl -no-opengl -no-webkit -no-phonon -no-style-motif -no-style-cde -no-style-cleanlooks -no-style-plastique -no-sql-sqlite -platform win32-g++ Edit 27 Jan 2010: Memory footprint data for both executables (GCC and Microsoft compiled) Memory footprint - Qt static compiled with GCC 4.4 Memory footprint - Qt static compiled with MS Visual Studio 2008 zz: http://www.formortals.com/build-qt-static-small-microsoft-intel-gcc-compiler/
个人分类: QT|3882 次阅读|0 个评论
生成matlab gui exe文件的方法
eaglezxw 2010-11-18 17:43
生成matlabguiexe文件的方法 1、在matlab的command窗口输入命令: mcc-BsglProcessing_Img.m,其中Processing_Img.m为gui的.m文件。 2、将第一步制作产生的Processing_Img.exe文件、Processing_Img.prj文件,以及MCRInstaller.exe文件拷贝到同一文件夹下,MCRInstaller.exe在 \\MATLAB\R2009a\toolbox\compiler\deploy\win32下面。 3、在要允许Processing_Img.exe的机子上运行MCRInstaller.exe,并安装在同一文件夹下,耐心 等待即可,然后运行Processing_Img.exe便OK.
个人分类: matlab开发|4504 次阅读|0 个评论
[转载]基于计算机视觉的GUI测试
w52191114 2010-8-13 01:28
基于计算机视觉的GUI测试 2010年1月22日 admin 发表评论 阅读评论 设计GUI很痛苦,编写GUI代码更痛苦,修改GUI代码更更痛苦,测试GUI代码更更更痛苦,所以就有了这么个东西 sikuli (死吧!苦力??),用计算机视觉进行自动GUI测试,以代替无比繁复的点击点击点击点击。 简单的说就是,测试人员编写测试脚本,计算机会自己去检查那个按钮,窗口,什么的到底出现没有。 论文 里有详细的解释,来自MIT CSAIL。 看起来是个不错的东西,不过作者也提到了,还有一些问题不能解决,比如现在sikuli虽然能检测某个按钮出现没有,但是如果其他地方莫名其妙出现个一个别的什么什么东西,sikuli是无能为力的,因为sikuli只知道到脚本指定的地方去检查,它还没有全屏自省的能力。 这里是 项目主 页。 媒体报道
个人分类: cvchina|2015 次阅读|0 个评论
MATLAB_转圈的球
snowdeer 2009-1-20 22:55
He=plot(0,0,'c.','markersize',24); hold on ezplot('0.0508*x^2-0.0702*x*y+0.0381*y^2-0.4531*x+0.2643*y+1', ) t=linspace(0,2*pi,100); set(gcf,'doublebuffer','on'); axis( ) k=1; i=1; while k s=get(gcf,'currentkey'); if strcmp(s,'space'); clc;k=0; end i=i+1; xe=5.9*cos(t(i))+5.67; ye=5.9*sin(t(i))+1.8; set(He,'xdata',xe,'ydata',ye); pause(0.1); end
个人分类: MATLAB类|3497 次阅读|0 个评论
纯 MATLAB 代码 编写gui ……计算器
snowdeer 2009-1-20 22:28
%一个简单的计算器 h0=figure('toolbar','none',... 'position', ,... 'name','简单计算器'); b0=uicontrol('parent',h0,... 'units','points',... 'tag','b0',... 'style','pushbutton',... 'string','0',... 'fontsize',12,... 'position', ,... 'backgroundcolor', ,... 'callback', ;,',... 'if k==''00'',',... 'k=''0'';,',... 'end,',... 'set(e1,''string'',k);,',... 'end']); b15=uicontrol('parent',h0,... 'units','points',... 'tag','b15',... 'style','pushbutton',... 'string','=',... 'fontsize',12,... 'position', ,... 'backgroundcolor', ,... 'callback', ); b11=uicontrol('parent',h0,... 'units','points',... 'tag','b11',... 'style','pushbutton',... 'string','+',... 'fontsize',12,... 'position', ,... 'backgroundcolor', ,... 'callback', ); b16=uicontrol('parent',h0,... 'units','points',... 'tag','b16',... 'style','pushbutton',... 'string','关闭',... 'fontsize',12,... 'position', ,... 'backgroundcolor', ,... 'callback','close'); b1=uicontrol('parent',h0,... 'units','points',... 'tag','b1',... 'style','pushbutton',... 'string','1',... 'fontsize',12,... 'position', ,... 'backgroundcolor', ,... 'callback', ;,',... 'set(e1,''string'',k);']); b2=uicontrol('parent',h0,... 'units','points',... 'tag','b2',... 'style','pushbutton',... 'string','2',... 'fontsize',12,... 'position', ,... 'backgroundcolor', ,... 'callback', ;,',... 'set(e1,''string'',k);']); b3=uicontrol('parent',h0,... 'units','points',... 'tag','b3',... 'style','pushbutton',... 'string','3',... 'fontsize',12,... 'position', ,... 'backgroundcolor', ,... 'callback', ;,',... 'set(e1,''string'',k);']); b14=uicontrol('parent',h0,... 'units','points',... 'tag','b14',... 'style','pushbutton',... 'string','/',... 'fontsize',12,... 'position', ,... 'backgroundcolor', ,... 'callback', ); b4=uicontrol('parent',h0,... 'units','points',... 'tag','b4',... 'style','pushbutton',... 'string','4',... 'fontsize',12,... 'position', ,... 'backgroundcolor', ,... 'callback', ;,',... 'set(e1,''string'',k);']); b5=uicontrol('parent',h0,... 'units','points',... 'tag','b5',... 'style','pushbutton',... 'string','5',... 'fontsize',12,... 'position', ,... 'backgroundcolor', ,... 'callback', ;,',... 'set(e1,''string'',k);']); b6=uicontrol('parent',h0,... 'units','points',... 'tag','b6',... 'style','pushbutton',... 'string','6',... 'fontsize',12,... 'position', ,... 'backgroundcolor', ,... 'callback', ;,',... 'set(e1,''string'',k);']); b13=uicontrol('parent',h0,... 'units','points',... 'tag','b13',... 'style','pushbutton',... 'string','*',... 'fontsize',12,... 'position', ,... 'backgroundcolor', ,... 'callback', ); b7=uicontrol('parent',h0,... 'units','points',... 'tag','b7',... 'style','pushbutton',... 'string','7',... 'fontsize',12,... 'position', ,... 'backgroundcolor', ,... 'callback', ;,',... 'set(e1,''string'',k);']); b8=uicontrol('parent',h0,... 'units','points',... 'tag','b8',... 'style','pushbutton',... 'string','8',... 'fontsize',12,... 'position', ,... 'backgroundcolor', ,... 'callback', ;,',... 'set(e1,''string'',k);']); b9=uicontrol('parent',h0,... 'units','points',... 'tag','b9',... 'style','pushbutton',... 'string','9',... 'fontsize',12,... 'position', ,... 'backgroundcolor', ,... 'callback', ;,',... 'set(e1,''string'',k);']); b12=uicontrol('parent',h0,... 'units','points',... 'tag','b12',... 'style','pushbutton',... 'string','-',... 'fontsize',12,... 'position', ,... 'backgroundcolor', ,... 'callback', ); e1=uicontrol('parent',h0,... 'units','points',... 'tag','e1',... 'style','edit',... 'horizontalalignment','right',... 'fontsize',12,... 'string','0',... 'position', ,... 'backgroundcolor', ); k=get(e1,'string'); i=0; m=0;
个人分类: MATLAB类|6313 次阅读|0 个评论

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-6-3 21:37

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部