QT study note _ Hello QT !, Qt study note _ hello
After some tangle, I still think swing is too much .. Continue QT
However, QT does not seem to be covered either. It takes a long time to configure the environment ..
Output hello QT first this time!
However, the box after running is too small. Although you can enlarge it by yourself, you do not know if you can call it during initialization? Come on ..
The output part uses HTML to modify the font and color, and can be mixed with HTML. This is an excellent choice.
#include <QApplication>#include <QLabel>int main(int argc,char *argv[]){ QApplication app(argc,argv); QLabel *label=new QLabel("
:
Qt entry hello program
That's because you chose git. Among the options, you can choose NONE.
1. Create a folder, such as E: \ Hello; and then create a new notepad in Hello and rename it as hellp. cpp. In this way, you can use NotePad to edit the program. After editing, save.
2. At the beginning (the one in the lower left corner of the screen), find the Qt Creator directory and find the Qt Command Prompt (I believe you can find it)
3. Open Qt Command Prompt
Run the cd command to switch to the Hello directory:
Specific command: cd E: \ Hello
4. Hello. pro:
The specific command is: qmake-project
5. compile the project to generate the Makefile:
Qmake Hello. pro
6. Compile the executable program:
Mingw32-make
In this case, you can find the newly generated program in the debug folder.
7. You can run hello.exe, which is generated in double steps.
Do not disable Qt Command Prompt. Otherwise, the system prompts that the DLL is missing.
To publish a program, you must copy the corresponding DLL to the folder where the program is located.
My Qt Study Notes 4 how to pop up the right-click menu in the QWidget window
Solution 1: Add QActions to a QWidget and set the contextMenuPolicy attribute of QWidget to the value of Qt: ActionsContextMenu. This makes the window menu a right-click menu consisting of the added QActions. 1: MyWidget (QWidget * parent) 2: QWidget (parent) 3: {4: setWindowTitle (tr (Context Menu Show 1); 5: // Add QActions6: addAction (newQAction (tr (& Open), this) for the window; 7: addAction (newQAction (QIcon (:/images/mark.png ), tr (& Mark), this); 8: addAction (newQAction (tr (& Quit), this); 9: // set the value of contextMenuPolicy to '10: setContextMenuPolicy (Qt: ActionsContextMenu) consisting of menu items with Actions as the pop-up menu; 11:} effect: Solution 2: override the protected virtual function of QWidget Void QWidget: contextMenuEvent (QContextMenuEvent * event) [virtual protected]. Set the contextMenuPolicy attribute of QWidget to the value of Qt: DefaultContextMenu, which is the default value and does not need to be displayed. 1: MyWidget (QWidget * parent) 2: QWidget (parent) 3: {4: setWindowTitle (tr (Context Menu Show 2); 5: setContextMenuPolicy (Qt:: DefaultContextMenu); // you do not need to set it. The default value is 6:} 7: 8: 9: voidMyWidget: contextMenuEvent (QContextMenuEvent * event) 10: {11: QMenu * menu = newQMenu (this); 12: menu-addAction (newQAction (tr (& Open), menu); 13: menu-addAction (newQAction (QIcon (: /images/mark.png), tr (& Mark), menu); 14: menu-addAction (NewQAction (tr (& Quit), menu); 15: menu-move (cursor (). pos (); // place the menu on the coordinates of the mouse. 16: menu-show (); 17:} effect: the above shows a new menu and some menu items in the contextMenuEvent function body for demonstration.