Dasturlash muhitida satrli ma’lumotlarni yaratish usullari. Ma’ruza Vizual dastur yaratish usullari Vizual dastur yaratish usullari
Формы- ui fayliga ikki marta sichqoncha chap tugmasi bosiladi
Vizual dastur yaratish usullari
QString s;
#include
QString a = "love"; QString str2("A yellow rose");
a.append(" chess");//satr oxiriga satr qo’shish
a.prepend("I "); //satr boshiga satr qo’shish
a.count(); //satrdagi simvollar sonini aniqlash size(), length()
a.toUpper(); //satrdagi simvollar katta harflarga aylantirish
a.toLower(); //satrdagi simvollar kichik harflarga aylantirish
a[0];//satrdagi birinchi simvolga murojaat
a.at(0)
Qt da satrlar. qstring tipi
QString str = "The night train";
// str satrning o’ng tomonidan boshlab 5 ta simvol olish
str.right(5)
// str satrning chap tomonidan boshlab 9 ta simvol olish
str.left(9)
// str satrning 4 simvolidan boshlab 5 ta simvol ajratish
str.mid(4, 5)
Qt da satrlar. qstring tipi
Satrlarni solishtirish
#include
QString::compare(a,b); a va b satrlarni solishtirish
if (QString::compare(a, b) ==0){}
Agar 0 dan kichik a satr b dan kichik
Agar 0 dan katta a satr b dan katta
if (QString::compare(a, b, Qt::CaseInsensitive) == 0) { }
Qt da satrlar. qstring tipi
Satrlarni tipini o’zgartirish
QString s1 = "12";
QString s2 = "15";
QString s3, s4;
// toInt() satrni butunga aylantirish.toFloat(), toDouble()
s1.toInt() + s2.toInt();
int n1 = 30;
int n2 = 40;
// setNum() yordamida butun sonni Qstring tipidagi satrga aylantirish
s3.setNum(n1) + s4.setNum(n2) ;
Qt da satrlar. qstring tipi
QString str = "7 white, 3 red roses.";
// Satr tarkibini aniqlash
foreach(QChar s, str) {
if (s.isDigit()) {
digits++;
} else if (s.isLetter()) {
letters++;
} else if (s.isSpace()) {
spaces++;
} else if (s.isPunct()) {
puncts++;
}
}
Qt da satrlar. qstring tipi
QString str = "Lovely";
str.append(" season");
// 10 pozitsiyadan boshlab 3 ta simvolni o’chirish
str.remove(10, 3);
// 7 pozitsiyadan boshlab 3 ta simvolni almashtirish
str.replace(7, 3, "girl");
// satrni tozalash
str.clear();
if (str.isEmpty()) {
cout << "The string is empty" << endl;
}
Label-O’zgarmas satr vidjeti Label-O’zgarmas satr vidjeti-XUSUSIYATLARI
ObjectName-Widjet nomi
Text- ko’rinadigan matn
alignment-Matnni Gor va Ver joylashishini sozlash
wordWrap-ko’p satrli namoyish
Font-Shrift nomi
Cursor-kursor ko’rinishi
tooltip-sichqoncha borganda ko’rinadigan matn
StatusTip-sichqoncha borganda status satrda ko’rinadigan matn
StyleSheet-matnni bezash,rang,fon
Lineedit-O’zgaradigan satr vidjeti Lineedit-O’zgaradigan satr vidjeti
ObjectName-Widjet nomi
Text- ko’rinadigan matn
alignment-Matnni Gor va Ver joylashishini sozlash
inputMask-kiritish qoidalarini o’rnatish
Font-Shrift nomi
Cursor-kursor ko’rinishi
tooltip-sichqoncha borganda ko’rinadigan matn
StatusTip-sichqoncha borganda status satrda ko’rinadigan matn
StyleSheet-matnni bezash,rang,fon
placeHolderText-eslatma matn
Clearbuttonenabled-tozalsh tugmasini yoqish
Lineedit-O’zgaradigan satr vidjeti
QString s=ui->lineEdit->text();
QString c=ui->label->text();
Do'stlaringiz bilan baham: |