Use all the selected values in another method.
-
I have a basic layout window with a toolbar. This tool bar with the following options:
Save
Retrieve> Packet Data
HelpWhen I click on "Recover > Packet Data" opens a new modal window with a form containing the following: QCalendar start, end QCalendar, QTime start, end QTime and other fields.
My code looks like this:
@
CARUIDataPackFilter::CARUIDataPackFilter(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);// List all types of packages on a listWidget
string a_app; // Em branco, obtem todosvector<string> ListPacotesDB;
m_objDataPck.GetPacketTypes(a_app, ListPacotesDB);for (int i=0;i<ListPacotesDB.size();i++)
{
ui.m_listPacote->addItem(ListPacotesDB[i].c_str());
}// List all stations on a listWidget
vector<string> ListaEstacoesDB;
m_objDataPck.GetGroundStations(ListaEstacoesDB);for (int i=0;i<ListaEstacoesDB.size();i++)
{
ui.m_listGS->addItem(ListaEstacoesDB[i].c_str());
}// Sets initial values of the fields of dialogue - Initial and Final Time
QString a_initialTime = "00:00:00.000";
QTime initialTime = QTime::fromString(a_initialTime, "hh:mm:ss.zzz");
ui.m_initialTime->setTime(initialTime);QString a_finalTime = "23:59:59.999";
QTime finalTime = QTime::fromString(a_finalTime, "hh:mm:ss.zzz");
ui.m_finalTime->setTime(finalTime);connect(ui.m_buttonOk, SIGNAL(clicked()), this, SLOT(OnBnClickedOk()));
}
CARUIDataPackFilter::~CARUIDataPackFilter()
{}
void CARUIDataPackFilter::OnBnClickedOk()
{// Recover the start date of QCalendarWidget
QString m_DateInitial = ui.m_initialDate->selectedDate().toString("dd/MM/yyyy");
string dateInitial = m_DateInitial.toStdString();// Recover the end date of QCalendarWidget
QString m_DateFinal = ui.m_finalDate->selectedDate().toString("dd/MM/yyyy");
string dateFinal = m_DateFinal.toStdString();// Recover the start time of QTimeEdit
QString m_TimeInitial = ui.m_initialTime->time().toString("hh:mm:ss.zzz");
string hourInitial = m_TimeInitial.toStdString();// Recover the end time of QTimeEdit
QString m_TimeFinal = ui.m_finalTime->time().toString("hh:mm:ss.zzz");
string hourFinal = m_TimeFinal.toStdString();// Recover, concatenates the start Date and start Time and converts to CSPTDateTime
CSPTDateTime objDateInitial;
dateInitial += " " + hourInitial;
objDateInitial.SetYMD(dateInitial, 2);// Recover, concatenates the end Date and end Time and converts to CSPTDateTime
CSPTDateTime objDateFinal;
dateFinal += " " + hourFinal;
objDateFinal.SetYMD(dateFinal, 2);// Concatenates the variable 'm_LinhaComando' the date and start time with the end date and time
m_LinhaComando =(QString) dateInitial.c_str();
m_LinhaComando+= ";";
m_LinhaComando+=(QString) dateFinal.c_str();// Extract (packet ID) string coming from the filter
m_LinhaComando += ";";
QString m_IdPacote = ui.m_lineIdPacote->text();
m_LinhaComando += m_IdPacote;// Returns all selected items in QListWidget (Package Types)
QList<QListWidgetItem *> itemList = ui.m_listPacote->selectedItems();m_LinhaComando += ";"; for(int i=0; i<itemList.size(); i++) { m_LinhaComando += itemList.at(i)->text(); if (i < itemList.size()) m_LinhaComando += ";"; }
// Returns all selected items in QListWidget (Types Stations)
itemList = ui.m_listGS->selectedItems();for(int i=0; i<itemList.size(); i++)
{
m_LinhaComando += itemList.at(i)->text();
if(i < itemList.size())
m_LinhaComando += ";";
}// Returns all selected items in QListWidget
itemList = ui.m_listTipoCom->selectedItems();for(int i=0; i<itemList.size(); i++)
{
m_LinhaComando += itemList.at(i)->text();
if(i < itemList.size())
m_LinhaComando += ";";
}
}
@Now I did the following:
I need to return this variable m_linhaComando, so that when the "ok" button is pressed I can use all the selected values in another method.
Can you help me?
@QString CARUIDataPackFilter::GetDataPack()
{
m_LinhaComando;
}@ -
Hi,
AFAICS you are just missing "return" in your getter