QT 4.8 在普通比较中崩溃

QT 4.8 crash at ordinary comparison

本文关键字:比较 崩溃 QT      更新时间:2023-10-16

请帮我解释一下意外的崩溃!!我有:

X.H

class x: QObject
   struct
    {
        struct
        {
            struct
            {
                int state;
                double curstring;
                QTimer timer_scroll;
                QTimer timer_done;
            }color;
            struct
            {
                int state;
                double curstring;
                QTimer timer_scroll;
                QTimer timer_done;
            }mono;
        }S2L_NOTIFY;

....等

x.cpp

void x::draw(const int type, QString str, bool isNeedAnswer)
{
    if(type == 3)
    {
        //here is crash!
        if(bitmap.S2L_NOTIFY.mono.state == 3 &&  bitmap.S2L_NOTIFY.color.state == 3)
        {

if((bitmap.S2L_NOTIFY.mono.state == 3)) -<不会在这里崩溃>

if((bitmap.S2L_NOTIFY.color.state == 3)) -<不会在这里崩溃>

请告诉我哪里错了或编译器错了?

问题是你的条件中有x,但函数x::rndfunc()是类x的成员函数......而不是变量。它应该是:

// "this" refers to the current instance of class x
if((this->y.z.f.nmb2 == NOTOK) && (this->y.z.f.nmb1 == NOTOK))

或者简单地:

// but the "this" isn't actually necessary
if((y.z.f.nmb2 == NOTOK) && (y.z.f.nmb1 == NOTOK))

(正如你所写)。

编辑:好的,所以原始问题中有一个错字,所以上面的内容不再相关。新的答案是:

f没有成员变量nmb1,只有nmb2

编辑#2:更多错别字。我的新答案:

你想做的事情看起来真的很混乱。别这样。