• 4700阅读
  • 5回复

Qt4程序在目标板上运行 segmentation fault [复制链接]

上一主题 下一主题
离线yuxuan
 
只看楼主 倒序阅读 楼主  发表于: 2009-09-10
void ClickLabel::mousePressEvent(QMouseEvent *event)
{
    qDebug(“debug");
    emit clicked();
}

上面这段程序编译完在目标板上运行正常,将语句qDebug(“debug");注释掉,重新编译运行,发生segmentation fault
请问这个问题怎么解决?
离线dbzhang800

只看该作者 1楼 发表于: 2009-09-10
这样的话,估计你的问题应该不在这个函数内,仔细调试下其他部分看看
离线yuxuan
只看该作者 2楼 发表于: 2009-09-10
引用第1楼dbzhang800于2009-09-10 18:02发表的  :
这样的话,估计你的问题应该不在这个函数内,仔细调试下其他部分看看


那为什么加上那个qDbug语句就OK呢?
离线dbzhang800

只看该作者 3楼 发表于: 2009-09-10
这个不能说明问题,只能说加上这条语句后你的程序bug没表现出来

对程序来说,即使在调试状态完全通过了,也不能说明release状态一切都是好的。

调程序累啊
离线yuxuan
只看该作者 4楼 发表于: 2009-09-10
谢谢提醒,好像是以下语句的问题:
file.open(QIODevice::ReadOnly | QIODevice::Text));
把QIODevice::Text属性去掉 程序就没问题了。

Qt4中关于QIODevice::Text的描述:
When reading, the end-of-line terminators are translated to '\n'. When writing, the end-of-line terminators are translated to the local encoding, for example '\r\n' for Win32.

哪位大侠能给个解释吗?还是不太明白为什么源程序如下:

bool simple::ReadData()
{
    QFile file(DataFile);
    if (!file.open(QIODevice::ReadOnly))// | QIODevice::Text))
    {
        QMessageBox::warning(this,tr("ReadData()"),
                    (tr("Cannot read file") + " %1 : %2.")
                    .arg(file.fileName())
                    .arg(file.errorString()));
        return false;
    }
    QTextStream in(&file);
    while (!in.atEnd())
    {
        QString line = in.readLine();
        QStringList datas = line.split(' ',QString::SkipEmptyParts);
        //qDebug("datas.count()=%d",datas.count());
        if (datas.count() > 8)
        {
            lineEdit_OutPower->setText(datas[0]);
            lineEdit_DCVoltage->setText(datas[1]);
            lineEdit_Frequency->setText(datas[2]);
            //
            lineEdit_Model->setText(datas[3]);
            lineEdit_VersionNumber->setText(datas[4]);
            lineEdit_VersionDate->setText(datas[5]);
            lineEdit_CVTModel->setText(datas[6]);
            lineEdit_DCInstructV->setText(datas[7]);
            lineEdit_MainCtrl->setText(datas[8]);
        }
    }
   return true;
}
离线yuxuan
只看该作者 5楼 发表于: 2009-09-11
文本内容超出了QLineEdit的显示宽度,所以发生段错误SIGSEGV。
快速回复
限100 字节
 
上一个 下一个