my_widget.cpp.html

来自「qt example for users」· HTML 代码 · 共 37 行

HTML
37
字号
<HTML><HEAD><TITLE>my_widget.cpp.html</TITLE></HEAD><BODY BGCOLOR=#FFFFFF TEXT=#000000><PRE><FONT COLOR=#a020f0>#include </FONT><FONT COLOR=#ff00ff>&lt;iostream&gt;</FONT>using namespace std;<FONT COLOR=#a020f0>#include </FONT><FONT COLOR=#ff00ff>&quot;my_widget.h&quot;</FONT><FONT COLOR=#008b8b>MyMainWindow::MyMainWindow</FONT>(QWidget* parent, <B><FONT COLOR=#2e8b57>const</FONT></B> <B><FONT COLOR=#2e8b57>char</FONT></B>* name):QMainWindow(parent, name){	CreateMenu();	<FONT COLOR=#5151fb>// create a button</FONT>	buttonExit = <B><FONT COLOR=#853e26>new</FONT></B> QPushButton(<FONT COLOR=#ff00ff>&quot;Exit&quot;</FONT>, <B><FONT COLOR=#853e26>this</FONT></B>, <FONT COLOR=#ff00ff>0</FONT>);	buttonExit-&gt;setGeometry(<FONT COLOR=#ff00ff>60</FONT>, <FONT COLOR=#ff00ff>60</FONT>, <FONT COLOR=#ff00ff>100</FONT>, <FONT COLOR=#ff00ff>40</FONT>);}<B><FONT COLOR=#2e8b57>void</FONT></B> MyMainWindow::CreateMenu(){	QPopupMenu* file = <B><FONT COLOR=#853e26>new</FONT></B> QPopupMenu(<B><FONT COLOR=#853e26>this</FONT></B>);	file-&gt;insertItem(<FONT COLOR=#ff00ff>&quot;Testing&quot;</FONT>);	file-&gt;insertItem(<FONT COLOR=#ff00ff>&quot;Exit&quot;</FONT>);	menuBar()-&gt;insertItem(<FONT COLOR=#ff00ff>&quot;File&quot;</FONT>, file);	QPopupMenu* help = <B><FONT COLOR=#853e26>new</FONT></B> QPopupMenu(<B><FONT COLOR=#853e26>this</FONT></B>);	help-&gt;insertItem(<FONT COLOR=#ff00ff>&quot;About&quot;</FONT>);	menuBar()-&gt;insertItem(<FONT COLOR=#ff00ff>&quot;Help&quot;</FONT>, help);}</PRE></BODY></HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?