Results 1 to 15 of 15

Thread: Updating Table Values.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Updating Table Values.

    There are three solutions:

    1) pass a pointer to the first dialog
    Qt Code:
    1. SecondDialog::SecondDialog( FirstDialog *ptr, QWidget *parent )
    2. : QDialog( parent ), _firstDialogPtr( ptr )
    3. {
    4. ...
    5. }
    6.  
    7. ...
    8.  
    9. void SecondDialog::processParams()
    10. {
    11. ...
    12. _firstDialogPtr->setSomenting( whatever );
    13. ...
    14. }
    To copy to clipboard, switch view to plain text mode 
    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:
    Qt Code:
    1. void FirstDialog::doSomething()
    2. {
    3. SecondDialog dlg( this );
    4. if( dlg.exec() == Qt::Accepted ) {
    5. someWidget->setSomething( dlg.something() ); // SecondDialog::something() returns the data you need
    6. ...
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 
    This is a bit better approach, since you can reuse SecondDialog for other purposes.

    3) Use signals and slots:
    Qt Code:
    1. void FirstDialog::showSecondDialog()
    2. {
    3. SecondDialog *dlg = new SecondDialog( this );
    4. dlg->setWFlags( dlg->getWFlags() | Qt::WDestructiveClose );
    5.  
    6. connect( dlg, SIGNAL( somethingChanged( int ) ),
    7. this, SLOT( setSomething( int ) ) );
    8. ...
    9.  
    10. dlg->show();
    11. }
    To copy to clipboard, switch view to plain text mode 
    This is the version with minimal coupling, but it also requires a bit more work than other ones.

  2. #2
    Join Date
    Feb 2007
    Posts
    22
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default 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.

  3. #3
    Join Date
    Feb 2007
    Posts
    22
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Updating Table Values.

    This is the second method u suggested

Similar Threads

  1. Replies: 11
    Last Post: 8th September 2006, 00:15
  2. displaying any table on a qdatatable
    By Philip_Anselmo in forum Newbie
    Replies: 4
    Last Post: 9th May 2006, 23:12
  3. creating table plugin
    By mgurbuz in forum Qt Programming
    Replies: 3
    Last Post: 28th April 2006, 14:50
  4. Adding row in a Table after selected row
    By ankurjain in forum Qt Programming
    Replies: 3
    Last Post: 20th April 2006, 19:06
  5. adding in values to table
    By therealjag in forum Qt Programming
    Replies: 2
    Last Post: 9th February 2006, 17:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.