注册 登录
编程论坛 QT论坛

求教:first(),last()两个函数怎么用

songyunxianr 发布于 2023-10-08 11:13, 358 次点击
今天看到QT两个字符串函数first()和last(),在自己机器的QT环境报错无此函数。环境:deepin 20.9,QT 5.15。
/home/hrhh-zengfc/qttest/sampl04_02_01/widget.cpp:-1: In member function ‘void Widget::on_pushButton_23_clicked()’:
/home/hrhh-zengfc/qttest/sampl04_02_01/widget.cpp:62: error: ‘class QString’ has no member named ‘first’
     QString str3 = str1.first(N + 1);            
                         ^~~~~
/home/hrhh-zengfc/qttest/sampl04_02_01/widget.cpp:64: error: ‘class QString’ has no member named ‘last’; did you mean ‘at’?
     str3 = str1.last(str1.size() - N - 1);        
                 ^~~~
请大神指教。
1 回复
#2
yiyanxiyin2023-10-08 17:48
这是6.0的函数
1