PDA

View Full Version : How to access the lineEdits values in TableView



grsandeep85
9th October 2009, 11:51
Hi All,

I have designed(Qt Designer-4.4.3) a QTableView and i need to enter the some data from another dialog with 4 lineEdits. how do i access the lineEdits values and display in the QTableView and here is the code snippet which i have implemented.


void ToolForm::addEntry()
{
ToolAddDialog tooladddialog;

if (tooladddialog.exec()) {
QString toolnumber = tooladddialog.toolnolineEdit->text();
QString tooldiameter = tooladddialog.diameterlineEdit->text();
QString toollength = tooladddialog.lengthlineEdit->text();
QString toolunits = tooladddialog.unitslineEdit->text();
addEntry(toolnumber, tooldiameter, toollength, toolunits);
}
}

Lykurg
10th October 2009, 19:15
Add getter functions to your ToolAddDialog. Something like:



class ToolAddDialog : public QDialog
{
public:
QString getDiameter() const
{
return ui.diameterlineEdit->text();
}
// and so on....
}

in your function you can access it via:

void ToolForm::addEntry()
{
ToolAddDialog tooladddialog;

if (tooladddialog.exec()) {
QString tooldiameter = tooladddialog.getDiameter();
//...
}
}