Re: Updating Table Values.
How many rows and columns your table has?
Re: Updating Table Values.
Re: Updating Table Values.
Re: Updating Table Values.
RawValueDisplay *a = new RawValueDisplay(this);
Re: Updating Table Values.
Quote:
Originally Posted by
kenny_isles
RawValueDisplay *a = new RawValueDisplay(this);
Are you sure? In such case this:
Code:
a.table1->setText( 1, 1, "qqq" );
shouldn't even compile. Maybe you have two "a" variables?
Re: Updating Table Values.
This is the code segment I am working with from morning. But None Seems to be working.
//-----------------------------------------------------------------------------------------------------
void Parameter_Selection_Dlg::ProcessParams()
{
// class QTable();
RawValueDisplay *a = new RawValueDisplay(this);
// this->table_1 = new QTable();
a->table1->setText( 1, 1, "qqq" );
// a->table1->hideColumn(1);
this->close();
// a->setUpdatesEnabled(TRUE);
// a->close();
// a->repaint(TRUE);
// a->exec();
// a->init();
// a->showMaximized();
}
//--------------------------------------------------------------------------------------------
:(
Re: Updating Table Values.
Quote:
Originally Posted by
kenny_isles
void Parameter_Selection_Dlg::ProcessParams()
{
// class QTable();
RawValueDisplay *a = new RawValueDisplay(this);
...
}
Here you are creating a new widget. If you want to update the table in existing one, you need a pointer to that previously created widget.
Re: Updating Table Values.
Well RawValueDisplay is the first dialog box. It is a class. So I am creating a object to that class to access the member table.
I am doing this is in VC++ style.
So Please tell me how to use that existing widget object.
:confused:
Re: Updating Table Values.
Quote:
Originally Posted by
kenny_isles
Well RawValueDisplay is the first dialog box. It is a class. So I am creating a object to that class to access the member table.
OK, but do you displaycreate RawValueDisplay first, then show Parameter_Selection_Dlg or the other way around (i.e. you show Parameter_Selection_Dlg first and then you want to show a new RawValueDisplay)?
Re: Updating Table Values.
Yes. I am able to launch the dialog boxes properly. But not able to set the values.
RawValueDisplay has the table and is the first DLG.
Parameter..............is the second DLG having a push button.
Once push button is pressed value should be displayed in table.
Re: Updating Table Values.
There are three solutions:
1) pass a pointer to the first dialog
Code:
SecondDialog
::SecondDialog( FirstDialog
*ptr,
QWidget *parent
) : QDialog( parent
), _firstDialogPtr
( ptr
) {
...
}
...
void SecondDialog::processParams()
{
...
_firstDialogPtr->setSomenting( whatever );
...
}
This is quite easy solution, but it also the worst one (except for the one with global variables which I won't even mention). It's bad, because both dialogs are tightly coupled.
2) use accessor methods to retrieve data from the SecondDialog:
Code:
void FirstDialog::doSomething()
{
SecondDialog dlg( this );
if( dlg.exec() == Qt::Accepted ) {
someWidget->setSomething( dlg.something() ); // SecondDialog::something() returns the data you need
...
}
}
This is a bit better approach, since you can reuse SecondDialog for other purposes.
3) Use signals and slots:
Code:
void FirstDialog::showSecondDialog()
{
SecondDialog *dlg = new SecondDialog( this );
dlg->setWFlags( dlg->getWFlags() | Qt::WDestructiveClose );
connect( dlg, SIGNAL( somethingChanged( int ) ),
this, SLOT( setSomething( int ) ) );
...
dlg->show();
}
This is the version with minimal coupling, but it also requires a bit more work than other ones.
Re: Updating Table Values.
Hi
The code is working however i want to know why the following approach dosnt work.
I will attach the code segment also.
Parameter_Selection_Dlg *b = new Parameter_Selection_Dlg(this);
b->show();
b->ChoosenParam_lb->setCurrentItem(0);
table1->setText(1,1,b->ChoosenParam_lb->currentText());
A is a dialog box which has a table and B is another class that has a list box.
As the above I am trying to upload the values into from B to A.
So ChoosenParam_lb is the List box name residing in Class B.
table1 is the name of the table.
Plz tell me as to why it is not showing the values.
With Regards
Kenny.
Re: Updating Table Values.
This is the second method u suggested
Re: Table Value not updating
Quote:
Originally Posted by
kenny_isles
Plz tell me as to why it is not showing the values.
Most likely because show() is a non-blocking call and "ChoosenParam_lb" is still empty when you check its current text. Try exec() instead of show() --- this way you will have a modal dialog. Otherwise you will need two methods: one that shows the dialog and another one that retrieves data from it after it was closed.
PS. Please, don't post the same question multiple times.