I. String qstring:
1. Operation string:
(1) "+" and "+ =" operators:
Example: qstring STR = "hello ,";
STR = STR + "World !";
STR + = "We come !"; // STR = "Hello, world! We come !"
(2) qstring: append () function :( it has the same function as the "+ =" operator)
For example, qstring str1 = "hello ,";
Qstring str2 = "World !";
Str1.append (str2); // str1 = "Hello, world !"
(3) qstring: sprintf () function:
Example: Str. sprintf ("% S % s", "welcome", "To You !"); // STR = "Welcome to you !"
(4) qstring: Arg () function:
Example: Str = qstring ("% 1 was born in % 2 ". arg ("I "). arg ("1995"); // STR = "I was born in 1995"
(5) Other qstring combinations:
① Insert () function: insert another string at a specific position
② Prepend () function: insert another string at the beginning
③ Replace () function: replace the original string with a specific string.
(6) qstring: trimmed () function: removes spaces at both ends of a string.
Qstring: simplified () function: functions the same as trimmed, and can replace multiple blank characters with a single character.
2. query string data:
(1) qstring: startswith (string, case sensitive): determines whether a string starts with a string.
(2) qstring: endswith (string, Case sensitivity): determines whether a string ends with a string.
(3) qstring: Contains (string, case sensitive): determines whether a string contains a string.
(4) Compare the length of two strings:
① Operator comparison operator (const qstring &)
② Localeawarecompare (const qstring &, const qstring &): If the former is smaller than the latter, a negative number is returned, and vice versa.
③ Compare (const qstring &, const qstring &, QT: casesensiti.pdf): returns a similar value to localeawarecompare (), but can be case-insensitive.
3. String Conversion:
(1) qstring: toint (): converts a string to an integer. Such as todouble () and tofloat.
4. Container class:
(1) qlist:
① If T is a pointer type or basic pointer size type, qlist <t> directly stores it in the array.
② If qlist <t> stores the object pointer, the Pointer Points to the actually stored object.
(2) qinilist: qinilist <t> is a chain list. It cannot use subscript and can only use iterator to access its array items.
(3) qvector: qvector <t> stores a group of values of the given data type T in the memory. You can use a subscript to access data items or an iterator to access data items.
④ Qmap class: qmap <key, T> provides a value ing from the key type to the T type.
⑤ Qhash class: qhash <key, T> has almost the same APIs as qmap (Application editing window ). It can organize its data in any order.
Ii. Controls: (select several important and common ones)
1. Button group: ① push button ② radio button
2. input control group: ① line edit ② time eidt time Edit
Example: Get local time:
Qlabel * datalabel = new qlabel ();
Qdatetime * datatime = new qdatatime (qdatetime: currentdatetime ());
Datalabel-> settext (datatime-> date (). tostring ());
Datalabel-> show ();
3. display control group: ① label Label ② qwebview Web View
4. space interval group: ① horizontal spacer horizontal interval ② vertical spacer vertical interval
5. layout management group: ① vertical layout ② grid layout
Layout example: qlabel * label = new qlabel (TR ("name :"));
Qlineedit * lineedit = new qlineedit ();
Qhboxlayout * layout = new qhboxlayout ();
Layout-> addwidget (Label );
Layout-> addwidget (lineedit );
Layout-> setlayout (layout );
6. Container group ① group box
7. Project view group: ① List View list view ② Tree View
8. Project control group: ① list widget list control ② tree widget tree control ③ table widget Table Control
Qt5 template library, tools and controls (new user logs)