Good day! I'm newbie in Qt, please, help me!
When I was writing my programs on C# 2008, there have been many ways to get the current value of the ComboBox. In Qt, I create QComboBox and insert items without using UI designer.
// items: codeList
codeList->addItem("PHP", "php");
codeList->addItem("JavaScript", "javascript");
// end of items for codeList
//items: dataExp
dataExp->addItem("Never delete", "N");
dataExp->addItem("10 Minutes", "10M");
dataExp->addItem("1 Hour", "1H");
dataExp->addItem("1 Day", "1D");
dataExp->addItem("1 Month", "1M");
// end of items for dataExp
// items: apiPrivate
apiPrivate->addItem("Public", "0");
apiPrivate->addItem("Private", "1");
// end of items for apiPrivate
dataExp = new QComboBox();
codeList = new QComboBox();
apiPrivate = new QComboBox();
// items: codeList
codeList->addItem("PHP", "php");
codeList->addItem("JavaScript", "javascript");
// end of items for codeList
//items: dataExp
dataExp->addItem("Never delete", "N");
dataExp->addItem("10 Minutes", "10M");
dataExp->addItem("1 Hour", "1H");
dataExp->addItem("1 Day", "1D");
dataExp->addItem("1 Month", "1M");
// end of items for dataExp
// items: apiPrivate
apiPrivate->addItem("Public", "0");
apiPrivate->addItem("Private", "1");
// end of items for apiPrivate
To copy to clipboard, switch view to plain text mode
My question: now to get value from selected item?
I try that:
private_stat = apiPrivate->itemText(apiPrivate->currentIndex());
prog_lang = codeList->itemText(codeList->currentIndex());
date_expire = dataExp->itemText(dataExp->currentIndex());
private_stat = apiPrivate->itemText(apiPrivate->currentIndex());
prog_lang = codeList->itemText(codeList->currentIndex());
date_expire = dataExp->itemText(dataExp->currentIndex());
To copy to clipboard, switch view to plain text mode
But returned default value
Tell me, what to do?
Bookmarks