Results 1 to 7 of 7

Thread: Tabs communication

  1. #1
    Join Date
    Feb 2006
    Posts
    87
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Arrow Tabs communication

    hey there, i have created 4 tabs in my program but they dont seem to communicate with each other by this i mean like i have this method in my third tab:

    Qt Code:
    1. int DesignTab::tariffReturn()
    2. {
    3. return tariff1->currentIndex();
    4. }
    To copy to clipboard, switch view to plain text mode 

    but when i try calling it from my 4th tab using DesignTab.tariffReturn( ) it gives an error when compiling saying the following:

    "expected primary expression before '.' token"

    does anyone know how i can call this method? or pass the value into my last tab?

  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: Tabs communication

    Could you post the line in which this error occurs?

  3. #3
    Join Date
    Feb 2006
    Posts
    87
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Tabs communication

    yeah sure here it is:

    Qt Code:
    1. if(DesignTab.tariffReturn() == 5) //period of rental is 5 year
    2. {
    3. cYear5->setText("");
    4. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Tabs communication

    Is DesignTab a pointer? show how it is declared.
    Save yourself some pain. Learn C++ before learning Qt.

  5. #5
    Join Date
    Feb 2006
    Posts
    87
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Tabs communication

    design tab is just the name of the tab constructor - heres me header file below:

    Qt Code:
    1. class CreatorTab : public QWidget
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. CreatorTab(const QFileInfo &fileInfo, QWidget *parent = 0);
    7.  
    8. private:
    9. Drawer *draw;
    10.  
    11. };
    12.  
    13.  
    14. class DemandsTab : public QWidget
    15. {
    16. Q_OBJECT
    17.  
    18.  
    19. public:
    20. DemandsTab(const QFileInfo &fileInfo, QWidget *parent = 0);
    21.  
    22.  
    23.  
    24. private slots:
    25.  
    26. void obtain_values(QTableWidgetItem *items);
    27. void random();
    28. void tableSize();
    29.  
    30. private:
    31.  
    32. void randGen(QTableWidgetItem *items);
    33. void changeSize(QTableWidgetItem *items);
    34.  
    35. QTableWidget *demands;
    36.  
    37. };
    38.  
    39.  
    40. class DesignTab : public QWidget
    41. {
    42. Q_OBJECT
    43.  
    44. public:
    45. DesignTab(const QFileInfo &fileInfo, QWidget *parent = 0);
    46.  
    47.  
    48. private slots:
    49. void network_cost();
    50. void tariffChosen();
    51.  
    52.  
    53. private:
    54. void n_cost();
    55. int BTSelected();
    56. int FranceSelected();
    57. int BelgSelected();
    58. int ItaliaSelected();
    59.  
    60. int BTPath();
    61. int FrancePath();
    62. int BelgPath();
    63. int ItaliaPath();
    64.  
    65. int tariffReturn();
    66.  
    67. int isChecked;
    68. QLineEdit *display;
    69. QLineEdit *display2;
    70. QLineEdit *display3;
    71.  
    72. QComboBox *tariff1;
    73.  
    74. QTableWidget *tariff;
    75.  
    76. QLabel *belgNote;
    77.  
    78. QRadioButton *radio1;
    79. QRadioButton *radio2;
    80. };
    81.  
    82.  
    83. class PriceTab : public QWidget
    84. {
    85. Q_OBJECT
    86.  
    87. public:
    88. PriceTab(const QFileInfo &fileInfo, QWidget *parent = 0);
    89.  
    90. private slots:
    91. void rentalCost();
    92. void priceSlot();
    93.  
    94.  
    95. private:
    96.  
    97. QLabel *price;
    98.  
    99. QLineEdit *initialCost;
    100. QLineEdit *cYear1, *cYear2, *cYear3, *cYear4, *cYear5;
    101. QLineEdit *rYear1, *rYear2, *rYear3, *rYear4, *rYear5;
    102.  
    103.  
    104. };
    105.  
    106.  
    107. class TabDialog : public QDialog
    108. {
    109. Q_OBJECT
    110.  
    111. public:
    112. TabDialog(const QString &fileName, QWidget *parent = 0);
    113.  
    114.  
    115.  
    116. private:
    117. QTabWidget *tabWidget;
    118.  
    119. void createActions();
    120. void createMenu();
    121. };
    122.  
    123.  
    124.  
    125.  
    126. #endif
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Tabs communication

    Well thats the problem. You can't call a member function on the class name. You must have an instance of the class. Your code should be:

    Qt Code:
    1. // Actually create the tab somewhere
    2. DesignTab tab = new DesignTab(...);
    3. ...
    4. if (tab->tariffReturn() == 5) //period of rental is 5 year
    5. {
    6. cYear5->setText("");
    7. }
    To copy to clipboard, switch view to plain text mode 
    Save yourself some pain. Learn C++ before learning Qt.

  7. The following user says thank you to Chicken Blood Machine for this useful post:

    therealjag (18th April 2006)

  8. #7
    Join Date
    Feb 2006
    Posts
    87
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Tabs communication

    cheers mate ur a life saver, i tried doing that before aswell but i guess my syntax was wrong!

Similar Threads

  1. Changing names of QTabWidget tabs
    By RThaden in forum Qt Programming
    Replies: 7
    Last Post: 29th January 2019, 21:25
  2. QTabWidget with same tabs
    By Djony in forum Qt Programming
    Replies: 20
    Last Post: 24th December 2011, 12:20
  3. How to make "west" tabs horizontal?
    By plumbum in forum Qt Programming
    Replies: 2
    Last Post: 7th June 2007, 10:32
  4. Switching off all tabs in QTabWidget
    By Gopala Krishna in forum Qt Programming
    Replies: 7
    Last Post: 30th August 2006, 17:10
  5. Removing Tabs
    By NewGuy in forum Qt Programming
    Replies: 6
    Last Post: 22nd July 2006, 22:46

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.