[SOLVED] qcombobox and clear()
-
If you are running your app in the debugger from the commandline, issue the bt command to gdb after the crash. From QtCreator, the backtrace should pop up automatically if a crash happens in debug mode.
-
im sorry but there is no popup.. im using QDevelop & QtDesigner in ubuntu..
-
QDevelop is not the same as QtCreator. And it is not a popup, it is part of the debug mode in that program.
Try this, on the commandline:
gdb path/to/your/executable
let your application crash, and then, still on the gdb prompt:
bt
That should give you your stack/back trace.
-
im sorry but the gdb /path/to/exe is not working. no program running..
Reading symbols from /home/edril/Documents/Desktop Projects/EquiApps/bin/EquiApps...done.
(gdb)cursor is always blinking..
-
i found the problem...
i disconnect first the signal in the dropdownProduct before using the clear().
@
void AddItemPurchaseOrderImpl::changeCategory(QString val)
{
disconnect(dropdownProduct, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeProduct(QString)));
bool firstrun = true;
dropdownProduct->clear();
if (val == "New Category") {
dropdownCategory->setEditable(true);
} else {
dropdownCategory->setEditable(false);
QSqlDatabase db = dbaseAddItemPO.dbConnect();
QVector<QMap<QString, QString> > products;
if (val == "Uncategorized") {
products = dbaseAddItemPO.getData("SELECT id, product_name FROM products WHERE category_id IS NULL");
} else {
QVector<QMap<QString, QString> > category = dbaseAddItemPO.getData("SELECT id FROM category WHERE category_name='" + val + "'");
products = dbaseAddItemPO.getData("SELECT id, product_name FROM products WHERE category_id='" + category[0].value("id") + "'");
}
if (products.size() != 0) {
for (int i=0; i < products.size(); i++) {
dropdownProduct->addItem(products[i].value("product_name"));
if (firstrun) {
QVector<QMap<QString, QString> > brands = dbaseAddItemPO.getData("SELECT brand_name FROM product_details WHERE products_id='" + products[i].value("id") + "'");
if (brands.size() != 0) {
for (int j=0; j < brands.size(); j++) {
dropdownBrand->addItem(brands[i].value("brand_name"));
}
}
firstrun = false;
}
}
}
dropdownProduct->addItem("New Product");
db.close();
}
dbaseAddItemPO.dbRemove();
connect(dropdownProduct, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeProduct(QString)));
}
@and reconnect it at the end.
thanx to all your replies.. -
Glad that you found the problem, but I would really like to advice you to learn some basic debugging skills. Problems of finding why an application crashes are something every developer will have to diagnose, sooner or later. Getting and reading & understanding a backtrace is a basic tool to fix those.
-
@fcrochik said in [SOLVED] qcombobox and clear():
I would venture a guess that the error is not on these lines of code.
Most likely is something that you doing somewhere else while processing signals that get triggered by adding/removing items. For example you may have code to process when the selected item changes on the combo - clearing the combo and adding new items will probably trigger that.
Yes you are right. I also facing the same problem.
-
@rohit713
The debugger is your friend in that case. -
@mrjj
Yes I disconnect the signal and after clearing the combobox I connect the signal again, now problem is solved by doing so. -
This post is deleted! -
@fcrochik thanks, you saved me!
-
This post is deleted!