0
点赞
收藏
分享

微信扫一扫

Qt(七)字符串常用功能,日期与时间


文章目录

  • ​​一、字符串常用功能​​
  • ​​日期与时间​​

一、字符串常用功能

创建widget 应用,使用了comboBox,简单UI设计如下:

Qt(七)字符串常用功能,日期与时间_字符串


按钮右击“转到槽”:

void Widget::on_pushButtonAppend_clicked()
{
QString str1,str2;
str1 = ui->comboBox_2->currentText();
str2 = ui->comboBox->currentText();
ui->lineEdit->setText(str1.append(str2));
}

void Widget::on_pushButton_10_clicked()
{
QString str1 = ui->comboBox_2->currentText();
ui->spinBox->setValue(str1.count());
}

void Widget::on_pushButton_14_clicked()
{
QString str1,str2;
str1 = ui->comboBox_2->currentText();
str2 = ui->comboBox->currentText();
ui->checkBox->setChecked(str1.endsWith(str2));
}

trimmedsimplified
trimmed 将字符串首尾的空格去掉
simplified将字符串首尾的空格去掉, 并将字符串中间的多个空格替换成一个空格。

indexOflastIndexOf
indexOf:查找字符串(默认从0位置开始,大小写敏感)
lastIndexOf:反向查找字符串(默认从0位置开始,大小写敏感)

日期与时间

QDateTime:日期时间数据类型,如2017-03-23 08:12:43。
QDateEdit: 编辑和显示日期的组件。
QDateTimeEdit:编辑和显示日期时间的组件。
QCalendarWidget:一 个用日历形式选择日期的组 件。
QTimer:定时器,如果周期为100,那么每100毫秒会发射一次timeout信号


举报

相关推荐

0 条评论