Hi. So I get this weird error message out from a QT application that i'm creating:

0xc0000005: read access violation at: 0x0, flags=0x0

Basically what I'm trying to do is to set in a QT List Widget an item of type QList Widget Item in which I store two things:
one, the name which will be seen when running the application
two, a unique indentifier, which in this case will be inserted by the user.
I've made in my application several validation regardless that id, so that it can't be two identically ids.
Ok, so here's the part of the code that's bugging me:

void MainWindow::itemsel(){
    QList<QListWidgetItem*> itm=ui->list->selectedItems();
    if (itm.size()==0) {
        return;
    }
    else{
        QVariant var=itm.first()->data(Qt::UserRole);
        int id=var.toInt();
        const domain* obj=ctrl->getbyid(id);
        ui->id_ln->setText(QString::number(id));
        ui->name_ln->setText(QString::fromStdString(obj->getname()));
    }
}

Ok, so, further in the program, I want to access inserted elements from the list, so I wrote a function which will display some things related to a given item. In this case, i'm trying to display the elements of an item which I inserted before.
ui->id_ln is a QTline edit in which I will display the unique id (and all goes fine till here).
ui->name_ln is a QTline edit in which I will display the name of the object.
So, my object (on which the item will point) conaints two things: an integer id, and a string name.
The part that yields the error is when I'm trying to set the text for the ui->name_ln to the one from my object.

const string& getname() const{
    return name;
}

is the getter for the name, that obj->getname().
By my error I would guess that i'm tryin to read more than I have allocated, or that something went wrong when trying to copy the string from my object, and that's bugging me.
I have an older application, same method, but there isn't any error regarding this situation. I have tried to write smaller applications, but still, the same error occures.
I tend to believe that it's something wrong with the QT C++ libraries, but again, one application works and the other doesn't.
Same thing happes if I try to exit the application when saving elements into a file:

void cont::save(){
    ofstream fout("dat.txt");
    vector<domain*> all=rp->getall();
    for (int i=0;i<(int)all.size();i++){
        fout<<all[i]->getid()<<','<<all[i]->getname()<<'\n';
    }
}

So, if you have some advices (but none related to: "do a debug", or "allocate space" etc.), or if you have encountered this kind of situation and have some solutions, please, share them.

Later Edit: I have followed the trail of errors and it led me to this:

    static _Elem *__CLRCALL_OR_CDECL copy(_Elem *_First1, const _Elem *_First2,
        size_t _Count)
        {   // copy [_First1, _First1 + _Count) to [_First2, ...)
        return ((_Elem *)_CSTD memcpy(_First1, _First2, _Count));
        }

which makes me believe that there has to be something with my libraries.

I myself i'm ashamed for posting this stuff up. I found my bugg, a tiny little mistake, which was ruining an entire application.

commented: Hey, it seems I'm stuck on the same problem. QT is bugging me a lot. Can you help me please? +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.