找回密码
 立即注册
收起左侧

QT中switch使用问题

5
回复
11017
查看
[复制链接]
累计签到:234 天
连续签到:1 天
来源: 2016-7-25 11:30:09 显示全部楼层 |阅读模式
5Qter豆
void Widget::timefunction(){    int i=0,j=0;    QChar c,h;    QString s=ui->textEdit->toPlainText();    foreach(c,s)                          //寻找到末尾    {        i++;        if(c=='*')        {            j=0;            foreach(h,s)                 //寻找到开头            {                switch(h)                {                    case 'a':ui->PaticleNum->setText(s.mid(j,i-1));                        break;                    default:break;                }                j++;            }        }    }}
为什么switch使用Qchar会报错?
switch quantity not an integer


最佳答案

查看完整内容

char QChar::toLatin1() const Returns the Latin-1 character equivalent to the QChar, or 0. This is mainly useful for non-internationalized software. Note: It is not possible to distinguish a non-Latin-1 character from a Latin-1 0 (NUL) character. Prefer to use unicode(), which does not have this ambiguity.
回复

使用道具 举报

累计签到:410 天
连续签到:1 天
2016-7-25 11:30:10 显示全部楼层
char QChar::toLatin1() const
Returns the Latin-1 character equivalent to the QChar, or 0. This is mainly useful for non-internationalized software.
Note: It is not possible to distinguish a non-Latin-1 character from a Latin-1 0 (NUL) character. Prefer to use unicode(), which does not have this ambiguity.
回复

使用道具 举报

尚未签到

2016-7-26 01:19:11 显示全部楼层
试试用Char代替QChar

点评

char可以,需要转换下。不过还没试过  详情 回复 发表于 2016-7-26 08:06
char是可以的。Qchar转换成char不会。  详情 回复 发表于 2016-7-26 08:04
回复

使用道具 举报

累计签到:234 天
连续签到:1 天
2016-7-26 08:04:41 显示全部楼层
Joey_Chan 发表于 2016-7-26 01:19
试试用Char代替QChar

char是可以的。Qchar转换成char不会。
回复

使用道具 举报

累计签到:234 天
连续签到:1 天
2016-7-26 08:06:47 显示全部楼层
Joey_Chan 发表于 2016-7-26 01:19
试试用Char代替QChar

char可以,需要转换下。不过还没试过
回复

使用道具 举报

尚未签到

2016-7-26 22:08:52 显示全部楼层
神奇号 发表于 2016-7-26 08:04
char是可以的。Qchar转换成char不会。

印象中QChar里面有函数能转换成char
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

公告
可以关注我们的微信公众号yafeilinux_friends获取最新动态,或者加入QQ会员群进行交流:190741849、186601429(已满) 我知道了