Results 1 to 2 of 2

Thread: QWizard registerField not seeming to store what is in a QLineEdit Box

  1. #1
    Join Date
    Jul 2010
    Posts
    11
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QWizard registerField not seeming to store what is in a QLineEdit Box

    Hi

    I am trying to create a wizard for my application which will create a new file with specific details filled in. I stored all variables in registerField with a diffrenet name, i can access the values from a spin box later in the wizard but cannot access any values from the QLineEdit boxes. Any help would be greatly appreciated. the code is inserted below.

    Qt Code:
    1. tabNamePage::tabNamePage(QWidget *parent) : QWizardPage(parent)
    2. {
    3. setTitle(tr("Tab Selection"));
    4. setSubTitle(tr("Please choose how many tabs "
    5. "and specify the names of each."));
    6.  
    7. Qt::Alignment Left = Qt::AlignLeft;
    8.  
    9. numberTabLabel = new QLabel(tr("Number of tabs:"));
    10. numberTabLabel->setMaximumWidth(100);
    11.  
    12. numberTabSpin = new QSpinBox;
    13. numberTabSpin->setFixedWidth(50);
    14. numberTabSpin->setMinimum(1);
    15. numberTabSpin->setMaximum(10);
    16.  
    17. tab1 = new QLineEdit;
    18. tab1->setVisible(true);
    19. tab1->setText("Tab 1");
    20. tab1->setFixedWidth(220);
    21. ...
    22. registerField("Number of tabs", numberTabSpin);
    23. registerField("tab1", tab1);
    24. registerField("Name of tab 2", tab2);
    25. registerField("Name of tab 3", tab3);
    26. registerField("Name of tab 4", tab4);
    27. registerField("Name of tab 5", tab5);
    28. registerField("Name of tab 6", tab6);
    29. registerField("Name of tab 7", tab7);
    30. registerField("Name of tab 8", tab8);
    31. registerField("Name of tab 9", tab9);
    32. registerField("Name of tab 10", tab10);
    33.  
    34. QHBoxLayout *Hlayout = new QHBoxLayout;
    35. Hlayout->addWidget(numberTabLabel);
    36. Hlayout->addWidget(numberTabSpin);
    37. Hlayout->setAlignment(Left);
    38.  
    39. QHBoxLayout *tab1Hlayout = new QHBoxLayout;
    40. tab1Hlayout->addWidget(tab1);
    41. tab1Hlayout->addWidget(tab2);
    42. tab1Hlayout->setAlignment(Left);
    43.  
    44. ...
    45.  
    46. Vlayout = new QVBoxLayout;
    47. Vlayout->addLayout(Hlayout);
    48. Vlayout->addLayout(tab1Hlayout);
    49. Vlayout->addLayout(tab2Hlayout);
    50. Vlayout->addLayout(tab3Hlayout);
    51. Vlayout->addLayout(tab4Hlayout);
    52. Vlayout->addLayout(tab5Hlayout);
    53. setLayout(Vlayout);
    54.  
    55. connect(numberTabSpin, SIGNAL(valueChanged(int)),this, SLOT(filltabnameboxes(int)));
    56. }
    57.  
    58.  
    59. whichVariablesPage1::whichVariablesPage1(QWidget *parent) : QWizardPage(parent)
    60. {
    61. QString tab1 = field("tab1").toString();
    62.  
    63. //QString title ="Variables Selection for ";
    64. setTitle(tab1);
    65. setSubTitle(tr("Specify which Variables you would like to include."));
    66.  
    67. QHBoxLayout *tab5Hlayout = new QHBoxLayout;
    68. QLabel *tab2 = new QLabel(tab1);
    69. tab5Hlayout->addWidget(tab2);
    70. setLayout(tab5Hlayout);
    71.  
    72. }
    73.  
    74. int whichVariablesPage1::nextId() const
    75. {
    76. int tabs = field("Number of tabs").toInt();
    77. if(tabs > 1)
    78. {
    79. return newWizard::Page_whichVariable2;
    80. } else {
    81. return newWizard::Page_conclusion;
    82. }
    83. }
    To copy to clipboard, switch view to plain text mode 

    Thanks

    James

  2. #2

    Default Re: QWizard registerField not seeming to store what is in a QLineEdit Box

    Hi everbody,

    first of all I'm sorry for bringing this thread up again. However, I'm facing the same problem.
    I've created a QWizard with several QWizardPages. On the first page I have a QLineEdit. The text entered there is stored using registerField.
    However if I try to access this value on the next page an empty string is returned.
    This is the way I registered my field:

    Qt Code:
    1. lineTest = new QLineEdit();
    2. registerField("test", lineTest);
    To copy to clipboard, switch view to plain text mode 

    And this is what I do to access the field on the next page:

    Qt Code:
    1. QString test = field("test").toString();
    To copy to clipboard, switch view to plain text mode 

    I'm very grateful for any help.

    Thanks a lot,
    Tara

Similar Threads

  1. Query - how to store ?
    By damodharan in forum Qt Programming
    Replies: 2
    Last Post: 31st May 2010, 12:59
  2. Store the filename of QIcon
    By Nithya in forum Qt Programming
    Replies: 1
    Last Post: 28th August 2008, 16:54
  3. QWizard, QComboBox and registerField() issue
    By RThaden in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2008, 12:18
  4. what is free store in C++ memory?
    By Masih in forum General Programming
    Replies: 6
    Last Post: 2nd July 2007, 22:25
  5. Turn off backing store
    By Rayven in forum Qt Programming
    Replies: 4
    Last Post: 8th February 2007, 18:01

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.