pheonixstorm
9th January 2011, 03:39
Built an app (don't sue me apple!) very similar to the addressbook tutorial (used QVector not QMap) and having issues using a next and previous function. As far as I can tell when it gets to checking for it == .begin() and changin it = .end() the it crashes instead of going to the end of the vector.
mpledit.cpp
void MplEdit::previousCargo()
{
if (it == MPLVec.begin())
it = MPLVec.end();
if (it == MPLVec.end()) {
ui->fileEdit->clear();
ui->categoryEdit->clear();
ui->priceEdit->clear();
ui->massEdit->clear();
ui->volumeEdit->clear();
ui->descEdit->clear();
}
ui->fileEdit->setText(it->getFile());
ui->categoryEdit->setText(it->getCategory());
ui->priceEdit->setText(it->getPrice());
ui->massEdit->setText(it->getMass());
ui->volumeEdit->setText(it->getVolume());
ui->descEdit->setText(it->getDesc());
it--;
}
mpledit.h
QVector<MPL> MPLVec;
QVector<MPL>::iterator it;
QVector<MPL>::const_iterator sav;
When i mouseover MPLVec.begin() it tells me that begin is const_iterator QVector::begin const when I *think* it should be telling me iterator QVector::begin () instead. Don't know if thats the issue or not... the const iterator save is only used in the saveCargo function and has no issues. I have tried clean project, removing all references to const_iterator (and just used two QVector:: iterator calls) but so far no luck. If you need me to post additional code let me know.
mpledit.cpp
void MplEdit::previousCargo()
{
if (it == MPLVec.begin())
it = MPLVec.end();
if (it == MPLVec.end()) {
ui->fileEdit->clear();
ui->categoryEdit->clear();
ui->priceEdit->clear();
ui->massEdit->clear();
ui->volumeEdit->clear();
ui->descEdit->clear();
}
ui->fileEdit->setText(it->getFile());
ui->categoryEdit->setText(it->getCategory());
ui->priceEdit->setText(it->getPrice());
ui->massEdit->setText(it->getMass());
ui->volumeEdit->setText(it->getVolume());
ui->descEdit->setText(it->getDesc());
it--;
}
mpledit.h
QVector<MPL> MPLVec;
QVector<MPL>::iterator it;
QVector<MPL>::const_iterator sav;
When i mouseover MPLVec.begin() it tells me that begin is const_iterator QVector::begin const when I *think* it should be telling me iterator QVector::begin () instead. Don't know if thats the issue or not... the const iterator save is only used in the saveCargo function and has no issues. I have tried clean project, removing all references to const_iterator (and just used two QVector:: iterator calls) but so far no luck. If you need me to post additional code let me know.