Hello, my Qt app gives the following run time error

HEAP[testApp.exe]:

QInvalid address specified to RtlFreeHeap( 0D920000, 0F29F1C0 )uoted Text Here

But it's free from error when i comment out these lines

        table->setCellWidget(currentRow,4,wid);
        table->setCellWidget(currentRow,2,++wid);
        table->setCellWidget(currentRow,1,(++wid));

Please i need help seriously.

    for(int i=0; i<currentSem->courses->count(); i++)
    {
        QVBoxLayout *vlayer = new QVBoxLayout[3];
        QWidget *wid = new QWidget[3];
        vlayer->setMargin(5);
       // vlayer->addSpacing(5);
        vlayer->addWidget(currentSem->courses->at(i)->gradeBox);
        wid->setLayout(vlayer);
        (++vlayer)->addWidget(currentSem->courses->at(i)->hrsBox);
        (++wid)->setLayout(vlayer);
        (++vlayer)->addWidget(currentSem->courses->at(i)->delButt);
        (++wid)->setLayout(vlayer);
        int currentRow = table->rowCount();
        table->insertRow(currentRow);
        table->setItem(currentRow,0, currentSem->courses->value(i)->tableItem);
        wid-=2;
        table->setCellWidget(currentRow,4,wid);
        table->setCellWidget(currentRow,2,++wid);
        table->setCellWidget(currentRow,1,(++wid));
        table->setRowHeight(i,50);
        currentSem->courses->at(i)->tableItem->setFont(*fontt);
    }

Recommended Answers

All 2 Replies

Looks like A QTableWidget automatically deteles any cell widgets you set.

That means that for each of the 3 cell widgets you set it will try to delete the widget individually. However you did not individually allocate those widgets, you allocated an array of widgets, that means that for 1 entry it will delete all three widgets where as for the other 2 it will try to delete a pointer that is not valid.

You need to allocate (call new) separately for each widget you wish to add to the table.

Thanks Banfa. It worked for seperate allocation.

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.