我有一个简单的 gui,它有一个文本字段、一个下拉菜单和一个执行按钮。我可以指定要查找的零件的名称和类,并通过将“开始”按钮连接到运行我已经创建的函数的插槽来调用函数。
但是,当 slot 函数完成所有操作时,它会调用 .in 中的一个函数xstring
,即删除一些大量xstring
. 它转到此功能:
void _Tidy(bool _Built = false,
size_type _Newsize = 0)
{ // initialize buffer, deallocating any storage
if (!_Built)
;
else if (this->_BUF_SIZE <= this->_Myres)
{ // copy any leftovers to small buffer and deallocate
pointer _Ptr = this->_Bx._Ptr;
this->_Getal().destroy(&this->_Bx._Ptr);
if (0 < _Newsize)
_Traits::copy(this->_Bx._Buf,
_STD addressof(*_Ptr), _Newsize);
this->_Getal().deallocate(_Ptr, this->_Myres + 1);
}
this->_Myres = this->_BUF_SIZE - 1;
_Eos(_Newsize);
}
我的程序在this->_Getal().deallocate(_Ptr, this->_Myres + 1);
.
这是gui的代码:
#include <QtGui>
#include <QApplication>
#include <QComboBox>
#include "gui.h"
#include <vector>
std::vector<std::string> PartClasses;
gui::gui(QWidget *parent) : QDialog(parent){
getPartClasses(PartClasses); //my own function, does not affect how the gui runs, just puts strings in PartClasses
label1 = new QLabel(tr("Insert Name (Optional):"));
label2 = new QLabel(tr("Class Name (Required):"));
lineEdit = new QLineEdit;
goButton = new QPushButton(tr("&Go"));
goButton->setDefault(true);
connect(goButton, SIGNAL(clicked()), this, SLOT(on_go_clicked()));
cb = new QComboBox();
for(int i = 0; i < PartClasses.size(); i++)
cb->addItem(QString::fromStdString(PartClasses[i]));
//*add widgets to layouts, removed for space*
setWindowTitle(tr("TEST"));
setFixedHeight(sizeHint().height());
}
void gui::on_go_clicked(){
std::string str(cb->currentText().toStdString());
updateDB(str, lineEdit->text().toUtf8().constData()); //my function, does not affect the gui.
QApplication::exit();
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
gui *stuff = new gui;
stuff->show();
return app.exec();
}
它在做什么?当我使用完插槽后,gui 不应该重新启动,以便我可以指定一个新对象吗?我怎样才能让它要么不删除这个对象,要么让它成功?