Results 1 to 4 of 4

Thread: How can I access QTableWidget from another QWizard page?

  1. #1
    Join Date
    Jun 2008
    Posts
    13
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How can I access QTableWidget from another QWizard page?

    Hi, I have a QWizard with a few pages and i need to access QTableWidget from another page. The reason I want to do it is that i want to load data from table while initalizing another page.

    Here's my page code:
    Qt Code:
    1. class SelectionPage : public QWizardPage
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. SelectionPage(QWidget *parent = 0);
    7. int nextId() const;
    8. void initializePage();
    9. void drawtable();
    10.  
    11. private:
    12. QLabel *topLabel,*middleLabel;
    13. QLineEdit *fileLineEdit;
    14. QPushButton *browsePushButton;
    15. QTableWidget *cgTableWidget;
    16.  
    17. private slots:
    18. void on_browsePushButton_clicked();
    19. };
    To copy to clipboard, switch view to plain text mode 

    I suppose i should make QTableWidget public, but even if i do it, i get this error message:
    error: object missing in reference to ‘SelectionPage::cgTableWidget’
    Any help would be appreciated

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

    Default Re: How can I access QTableWidget from another QWizard page?

    Could you post the line in which you access that variable? According to the error message you don't specify from which SelectionPage object you want to get the cgTableWidget variable. You need something like:
    Qt Code:
    1. selectionPage->cgTableWidget->...
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jun 2008
    Posts
    13
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How can I access QTableWidget from another QWizard page?

    I have another page called OptionsPage:
    Qt Code:
    1. class OptionsPage : public QWizardPage
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. OptionsPage(QWidget *parent = 0);
    7. int nextId() const;
    8. void initializePage();
    9.  
    10. private:
    11. QLabel *topLabel;
    12. };
    To copy to clipboard, switch view to plain text mode 

    and here is how i am trying to get data:
    Qt Code:
    1. void OptionsPage::initializePage()
    2. {
    3. SelectionPage::cgTableWidget->item(0, 0);
    4. }
    To copy to clipboard, switch view to plain text mode 

    If i replace SelectionPage::cgTableWidget with SelectionPage->cgTableWidget i get this error:
    error: expected unqualified-id before ‘->’ token

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

    Default Re: How can I access QTableWidget from another QWizard page?

    SelectionPage is a class. You have to use an object of this class.

    In OptionsPage you have "topLabel" which is a pointer to QLabel object. When you want to access that object you use "topLabel->something()", not "QLabel::something()". And you have to do the same with SelectionPage.

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.