Results 1 to 14 of 14

Thread: Problem with connect?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2013
    Location
    England
    Posts
    13
    Thanks
    7
    Qt products
    Qt5
    Platforms
    Windows

    Unhappy Problem with connect?

    Hey,

    I am currently creating a program and have encountered a small problem.

    I have a QWidget (MainMenu) with a pushbutton on and a slot called void MainMenu::button1Clicked();
    On the click of this button, it closes MainMenu and opens up my second widget (PageTwo).

    This works fine, however on PageTwo, the pushbutton to return to MainMenu does not work, it simply closes the widget as it is supposed to, but doesnt run MainMenu



    Mainmenu class: (button works fine!)
    Qt Code:
    1. MainMenu::MainMenu(QWidget *parent)
    2. : QWidget(parent)
    3.  
    4. {
    5.  
    6. QWidget *MainMenu1 = new QWidget;
    7.  
    8. QPushButton *button1 = new QPushButton;
    9. connect(button1, SIGNAL(clicked()),MainMenu1, SLOT(close()));
    10. connect(button1,SIGNAL(clicked()),this,SLOT(button1Clicked()));
    11.  
    12. MainMenu -> show();
    13.  
    14. }
    15.  
    16.  
    17.  
    18. void MainMenu::button1Clicked()
    19. {
    20. Page2 w;
    21.  
    22. }
    To copy to clipboard, switch view to plain text mode 

    My second class , it opens up fine but will not run MainMenu when the button is clicked as it does the first time
    Qt Code:
    1. Page2::Page2(QWidget *parent)
    2. : QWidget(parent)
    3. {
    4.  
    5.  
    6. QWidget *PageTwo = new QWidget;
    7.  
    8. QPushButton *button2 = new QPushButton;
    9. connect(button2, SIGNAL(clicked()),PageTwo, SLOT(close()));
    10. connect(button2,SIGNAL(clicked()),this,SLOT(button2Clicked()));
    11.  
    12. PageTwo -> show();
    13.  
    14. }
    15.  
    16.  
    17.  
    18. void Page2::button2Clicked()
    19. {
    20. MainMenu w;
    21.  
    22. }
    To copy to clipboard, switch view to plain text mode 



    Thanks in advance for any replies.. It is really confusing me as to why the first button works perfectly fine but the second one will not even though the code is practically the same...
    P.S i am not recieving any errors, main menu is just not showing!
    Last edited by Jake123; 22nd January 2013 at 16:17.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with connect?

    Please show real code. What you posted will not even compile.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Problem with connect?

    Problem in you code:
    1. You creating objects of the same class in the class constructor, this will never work. The reson you feel it works if some kind of errror. Did you ever notice that you have two MainMenu's
    2. Create Objects using new operator (i.e. on the heap).
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  4. #4
    Join Date
    Jan 2013
    Location
    England
    Posts
    13
    Thanks
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Problem with connect?

    Thanks, but that doesn't answer my question, that is just spotting errors in the code which i made to try and highlight and give an example of the problem. The fact is, why will my program run and even allow the first set of pushbuttons to work, linking to the next widget - but after that no more pushbuttons will work. They simply execute the first command (to close to widget) and do not run the destination class

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Problem with connect?

    Quote Originally Posted by Jake123 View Post
    Thanks, but that doesn't answer my question
    Yes, but without seeing a minimal compilable example demonstrating your problem we hardly could.

  6. #6
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Problem with connect?

    See if you can userstand this code (Note this works perfectly)
    Qt Code:
    1. MainMenu::MainMenu(QWidget *parent)
    2. : QWidget(parent)
    3. {
    4. setAttribute(Qt::WA_DeleteOnClose);
    5. QPushButton *button1 = new QPushButton("PushButton 1", this);
    6. connect(button1,SIGNAL(clicked()),this,SLOT(button1Clicked()));
    7.  
    8. this->show();
    9. }
    10.  
    11. void MainMenu::button1Clicked()
    12. {
    13. Page2 *w = new Page2();
    14. w->show();
    15.  
    16. this->close();
    17. }
    18.  
    19. Page2::Page2(QWidget *parent)
    20. : QWidget(parent)
    21. {
    22. setAttribute(Qt::WA_DeleteOnClose);
    23. QPushButton *button2 = new QPushButton("PushButton 2", this);
    24. connect(button2,SIGNAL(clicked()),this,SLOT(button2Clicked()));
    25.  
    26. this->show();
    27. }
    28.  
    29. void Page2::button2Clicked()
    30. {
    31. MainMenu *w = new MainMenu();
    32. w->show();
    33.  
    34. this->close();
    35. }
    To copy to clipboard, switch view to plain text mode 

    Note: It will work functionally only
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  7. The following user says thank you to Santosh Reddy for this useful post:

    Jake123 (22nd January 2013)

  8. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with connect?

    Quote Originally Posted by Jake123 View Post
    Thanks, but that doesn't answer my question, that is just spotting errors in the code which i made to try and highlight and give an example of the problem. The fact is, why will my program run and even allow the first set of pushbuttons to work, linking to the next widget - but after that no more pushbuttons will work. They simply execute the first command (to close to widget) and do not run the destination class
    If the code is made up and not a real world case, why should anyone bother fixing it?

    You are aware what the following code does, right? I mean, you know "obj" will be destroyed when fun() returns?

    Qt Code:
    1. void fun() {
    2. Class obj;
    3. }
    To copy to clipboard, switch view to plain text mode 

    I think what OP wants (but is unable to express his wishes) is to open back the original MainMenu instance.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #8
    Join Date
    Jan 2013
    Location
    England
    Posts
    13
    Thanks
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Problem with connect?

    Yeah, i understand that and you are correct in understanding what i want.. I have posted my full code in a new thread

  10. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with connect?

    Quote Originally Posted by Jake123 View Post
    Yeah, i understand that
    So why do you do that?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #10
    Join Date
    Jan 2013
    Location
    England
    Posts
    13
    Thanks
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Problem with connect?

    Quote Originally Posted by wysota View Post
    So why do you do that?

    In the first class (MainMenu) it worked in running the Quad class and therefore creating the widget - so i assumed it was the correct way to do it. What would you suggest instead?

  12. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with connect?

    I would suggest to read a bit about object oriented programming and C++ in particular before taking on any serious programming. Using Qt without decent C++ skills is going to backfire sooner or later.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #12
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Problem with connect?

    This is defenetly not what you should do, but just in case if you want to see your code work the way you expect for now, have a look below
    Qt Code:
    1. class MainMenu : public QWidget
    2. {
    3. Q_OBJECT
    4. public:
    5. explicit MainMenu(QWidget *parent = 0);
    6. public slots:
    7. void Menu2QuadClicked();
    8. };
    9.  
    10. class Quadratic : public QWidget
    11. {
    12. Q_OBJECT
    13. public:
    14. explicit Quadratic(QWidget *parent = 0);
    15. public slots:
    16. void Quad2MenuClicked();
    17. };
    18.  
    19. MainMenu::MainMenu(QWidget *parent)
    20. : QWidget(parent)
    21. {
    22. QWidget *MainMenuW = this;
    23.  
    24. MainMenuW -> setWindowTitle("Mainmenu");
    25. MainMenuW -> setStyleSheet("background-image: url(Graphics/MainMenu.png)");
    26. QSize appsize(1200,650);
    27. MainMenuW -> setFixedSize(appsize);
    28. MainMenuW -> resize(appsize);
    29.  
    30. QSize ButtonSize(200,68);
    31. QPushButton *Menu2Menu = new QPushButton;
    32. Menu2Menu -> setFixedSize(ButtonSize);
    33. Menu2Menu -> setStyleSheet("background-image: url(Buttons/MM1.png)");
    34.  
    35. QPushButton *Menu2Quad = new QPushButton;
    36. Menu2Quad -> setFixedSize(ButtonSize);
    37. Menu2Quad -> setStyleSheet("background-image: url(Buttons/Q.png)");
    38. connect(Menu2Quad, SIGNAL(clicked()),MainMenuW, SLOT(close()));
    39. connect(Menu2Quad,SIGNAL(clicked()),this,SLOT(Menu2QuadClicked()));
    40.  
    41. QPushButton *Menu2Trig = new QPushButton;
    42. Menu2Trig -> setFixedSize(ButtonSize);
    43. Menu2Trig -> setStyleSheet("background-image: url(Buttons/T.png)");
    44.  
    45. QPushButton *Menu2Pythag = new QPushButton;
    46. Menu2Pythag -> setFixedSize(ButtonSize);
    47. Menu2Pythag -> setStyleSheet("background-image: url(Buttons/P.png)");
    48.  
    49. QPushButton *Menu2Simul = new QPushButton;
    50. Menu2Simul -> setFixedSize(ButtonSize);
    51. Menu2Simul -> setStyleSheet("background-image: url(Buttons/S.png)");
    52.  
    53. QPushButton *Menu22D = new QPushButton;
    54. Menu22D -> setFixedSize(ButtonSize);
    55. Menu22D -> setStyleSheet("background-image: url(Buttons/2.png)");
    56.  
    57. QPushButton *Menu23D = new QPushButton;
    58. Menu23D -> setFixedSize(ButtonSize);
    59. Menu23D -> setStyleSheet("background-image: url(Buttons/3.png)");
    60.  
    61. QSpacerItem *Spacer0001 = new QSpacerItem(100, 450, QSizePolicy::Ignored, QSizePolicy::Ignored);
    62.  
    63. QGridLayout *MainMenuLayout = new QGridLayout;
    64. MainMenuLayout -> addItem(Spacer0001,1,1,1,1,Qt::AlignLeft);
    65. MainMenuLayout -> addWidget(Menu2Menu,3,1,1,1,Qt::AlignLeft);
    66. MainMenuLayout -> addWidget(Menu2Quad,4,1,1,1,Qt::AlignLeft);
    67. MainMenuLayout -> addWidget(Menu2Pythag,5,1,1,1,Qt::AlignLeft);
    68. MainMenuLayout -> addWidget(Menu2Trig,6,1,1,1,Qt::AlignLeft);
    69. MainMenuLayout -> addWidget(Menu2Simul,7,1,1,1,Qt::AlignLeft);
    70. MainMenuLayout -> addWidget(Menu22D,8,1,1,1,Qt::AlignLeft);
    71. MainMenuLayout -> addWidget(Menu23D,9,1,1,1,Qt::AlignLeft);
    72. MainMenuW-> setLayout(MainMenuLayout);
    73.  
    74. MainMenuW -> show();
    75. }
    76.  
    77. void MainMenu::Menu2QuadClicked()
    78. {
    79. Quadratic *w = new Quadratic;
    80. w->show();
    81. }
    82.  
    83. Quadratic::Quadratic(QWidget *parent)
    84. : QWidget(parent)
    85. {
    86. QWidget *Quad = this;
    87.  
    88. Quad -> setWindowTitle("Quad");
    89. Quad -> setStyleSheet("background-image: url(Graphics/Quadratics.png)");
    90. QSize appsize(1200,650);
    91. Quad -> setFixedSize(appsize);
    92. Quad -> resize(appsize);
    93.  
    94. QSize ButtonSize(200,68);
    95. QPushButton *Quad2Menu = new QPushButton;
    96. Quad2Menu -> setFixedSize(ButtonSize);
    97. Quad2Menu -> setStyleSheet("background-image: url(Buttons/MM.png)");
    98. connect(Quad2Menu,SIGNAL(clicked()),Quad,SLOT(close()));
    99. connect(Quad2Menu,SIGNAL(clicked()),this,SLOT(Quad2MenuClicked()));
    100.  
    101. QPushButton *Quad2Quad = new QPushButton;
    102. Quad2Quad -> setFixedSize(ButtonSize);
    103. Quad2Quad -> setStyleSheet("background-image: url(Buttons/Q1.png)");
    104.  
    105. QPushButton *Quad2Trig = new QPushButton;
    106. Quad2Trig -> setFixedSize(ButtonSize);
    107. Quad2Trig -> setStyleSheet("background-image: url(Buttons/T.png)");
    108.  
    109. QPushButton *Quad2Pyth = new QPushButton;
    110. Quad2Pyth -> setFixedSize(ButtonSize);
    111. Quad2Pyth -> setStyleSheet("background-image: url(Buttons/P.png)");
    112.  
    113. QPushButton *Quad2Sim = new QPushButton;
    114. Quad2Sim -> setFixedSize(ButtonSize);
    115. Quad2Sim -> setStyleSheet("background-image: url(Buttons/S.png)");
    116.  
    117. QPushButton *Quad22D = new QPushButton;
    118. Quad22D -> setFixedSize(ButtonSize);
    119. Quad22D -> setStyleSheet("background-image: url(Buttons/2.png)");
    120.  
    121. QPushButton *Quad23D = new QPushButton;
    122. Quad23D -> setFixedSize(ButtonSize);
    123. Quad23D -> setStyleSheet("background-image: url(Buttons/3.png)");
    124.  
    125. QSpacerItem *Spacer0001 = new QSpacerItem(100, 450, QSizePolicy::Ignored, QSizePolicy::Ignored);
    126.  
    127. QGridLayout *QuadLayout = new QGridLayout;
    128. QuadLayout -> addItem(Spacer0001,1,1,1,1,Qt::AlignLeft);
    129. QuadLayout -> addWidget(Quad2Menu,3,1,1,1,Qt::AlignLeft);
    130. QuadLayout -> addWidget(Quad2Quad,4,1,1,1,Qt::AlignLeft);
    131. QuadLayout -> addWidget(Quad2Pyth,5,1,1,1,Qt::AlignLeft);
    132. QuadLayout -> addWidget(Quad2Trig,6,1,1,1,Qt::AlignLeft);
    133. QuadLayout -> addWidget(Quad2Sim,7,1,1,1,Qt::AlignLeft);
    134. QuadLayout -> addWidget(Quad22D,8,1,1,1,Qt::AlignLeft);
    135. QuadLayout -> addWidget(Quad23D,9,1,1,1,Qt::AlignLeft);
    136. Quad -> setLayout(QuadLayout);
    137.  
    138. Quad -> show();
    139. }
    To copy to clipboard, switch view to plain text mode 

    Here is how the story goes.

    1. Create and show MainMenu (Say M1)
    2. Click PushButton (Say MP1) of M1, this will create and show a new Quadratic (Say Q1) and close M1.
    3. Click PushButton (Say QP1) of Q1, this will create and show a new MainMenu (Say M2) and close Q1. Important part is that M1 is closed in earlier step and no way get to it, an hence a memory leak.
    4. Click PushButton on M2 will repeat the story from step 2.

    Is this the story you wanted?
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  14. The following user says thank you to Santosh Reddy for this useful post:

    Jake123 (23rd January 2013)

  15. #13
    Join Date
    Jan 2013
    Location
    England
    Posts
    13
    Thanks
    7
    Qt products
    Qt5
    Platforms
    Windows

    Post Problem Continued (code)

    (Real Code)

    So When i click my quad button, it successfuly runs the Quad class and opens the quad widget, aswell as closing the main menu widget (as it should)
    However when I click the Main Menu button on the quad page, it closes the widget (as it should) but DOES NOT run the main menu widget.


    Main Menu Class:
    Qt Code:
    1. #include "mainmenu.h"
    2. #include "quadratic.h"
    3.  
    4.  
    5.  
    6. MainMenu::MainMenu(QWidget *parent)
    7. : QWidget(parent)
    8.  
    9. {
    10.  
    11. QWidget *MainMenuW = new QWidget;
    12.  
    13. MainMenuW -> setWindowTitle("Mainmenu");
    14. MainMenuW -> setStyleSheet("background-image: url(Graphics/MainMenu.png)");
    15. QSize appsize(1200,650);
    16. MainMenuW -> setFixedSize(appsize);
    17. MainMenuW -> resize(appsize);
    18.  
    19. QSize ButtonSize(200,68);
    20. QPushButton *Menu2Menu = new QPushButton;
    21. Menu2Menu -> setFixedSize(ButtonSize);
    22. Menu2Menu -> setStyleSheet("background-image: url(Buttons/MM1.png)");
    23.  
    24.  
    25.  
    26. QPushButton *Menu2Quad = new QPushButton;
    27. Menu2Quad -> setFixedSize(ButtonSize);
    28. Menu2Quad -> setStyleSheet("background-image: url(Buttons/Q.png)");
    29. connect(Menu2Quad, SIGNAL(clicked()),MainMenuW, SLOT(close()));
    30. connect(Menu2Quad,SIGNAL(clicked()),this,SLOT(Menu2QuadClicked()));
    31.  
    32.  
    33. QPushButton *Menu2Trig = new QPushButton;
    34. Menu2Trig -> setFixedSize(ButtonSize);
    35. Menu2Trig -> setStyleSheet("background-image: url(Buttons/T.png)");
    36.  
    37.  
    38.  
    39.  
    40. QPushButton *Menu2Pythag = new QPushButton;
    41. Menu2Pythag -> setFixedSize(ButtonSize);
    42. Menu2Pythag -> setStyleSheet("background-image: url(Buttons/P.png)");
    43.  
    44.  
    45.  
    46.  
    47. QPushButton *Menu2Simul = new QPushButton;
    48. Menu2Simul -> setFixedSize(ButtonSize);
    49. Menu2Simul -> setStyleSheet("background-image: url(Buttons/S.png)");
    50.  
    51.  
    52.  
    53.  
    54. QPushButton *Menu22D = new QPushButton;
    55. Menu22D -> setFixedSize(ButtonSize);
    56. Menu22D -> setStyleSheet("background-image: url(Buttons/2.png)");
    57.  
    58.  
    59.  
    60.  
    61. QPushButton *Menu23D = new QPushButton;
    62. Menu23D -> setFixedSize(ButtonSize);
    63. Menu23D -> setStyleSheet("background-image: url(Buttons/3.png)");
    64.  
    65.  
    66. QSpacerItem *Spacer0001 = new QSpacerItem(100, 450, QSizePolicy::Ignored, QSizePolicy::Ignored);
    67.  
    68.  
    69.  
    70.  
    71. QGridLayout *MainMenuLayout = new QGridLayout;
    72. MainMenuLayout -> addItem(Spacer0001,1,1,1,1,Qt::AlignLeft);
    73. MainMenuLayout -> addWidget(Menu2Menu,3,1,1,1,Qt::AlignLeft);
    74. MainMenuLayout -> addWidget(Menu2Quad,4,1,1,1,Qt::AlignLeft);
    75. MainMenuLayout -> addWidget(Menu2Pythag,5,1,1,1,Qt::AlignLeft);
    76. MainMenuLayout -> addWidget(Menu2Trig,6,1,1,1,Qt::AlignLeft);
    77. MainMenuLayout -> addWidget(Menu2Simul,7,1,1,1,Qt::AlignLeft);
    78. MainMenuLayout -> addWidget(Menu22D,8,1,1,1,Qt::AlignLeft);
    79. MainMenuLayout -> addWidget(Menu23D,9,1,1,1,Qt::AlignLeft);
    80. MainMenuW-> setLayout(MainMenuLayout);
    81.  
    82.  
    83.  
    84.  
    85. MainMenuW -> show();
    86.  
    87. }
    88.  
    89. void MainMenu::Menu2QuadClicked()
    90. {
    91. Quadratic w;
    92.  
    93.  
    94. }
    To copy to clipboard, switch view to plain text mode 



    Quad Class
    Qt Code:
    1. #include "mainmenu.h"
    2. #include "quadratic.h"
    3.  
    4.  
    5. Quadratic::Quadratic(QWidget *parent) :
    6. QWidget(parent)
    7. {
    8.  
    9. QWidget *Quad = new QWidget;
    10.  
    11. Quad -> setWindowTitle("Quad");
    12. Quad -> setStyleSheet("background-image: url(Graphics/Quadratics.png)");
    13. QSize appsize(1200,650);
    14. Quad -> setFixedSize(appsize);
    15. Quad -> resize(appsize);
    16.  
    17. QSize ButtonSize(200,68);
    18. QPushButton *Quad2Menu = new QPushButton;
    19. Quad2Menu -> setFixedSize(ButtonSize);
    20. Quad2Menu -> setStyleSheet("background-image: url(Buttons/MM.png)");
    21. connect(Quad2Menu,SIGNAL(clicked()),Quad,SLOT(close()));
    22. connect(Quad2Menu,SIGNAL(clicked()),this,SLOT(Quad2MenuClicked()));
    23.  
    24.  
    25. QPushButton *Quad2Quad = new QPushButton;
    26. Quad2Quad -> setFixedSize(ButtonSize);
    27. Quad2Quad -> setStyleSheet("background-image: url(Buttons/Q1.png)");
    28.  
    29.  
    30.  
    31. QPushButton *Quad2Trig = new QPushButton;
    32. Quad2Trig -> setFixedSize(ButtonSize);
    33. Quad2Trig -> setStyleSheet("background-image: url(Buttons/T.png)");
    34.  
    35.  
    36.  
    37.  
    38. QPushButton *Quad2Pyth = new QPushButton;
    39. Quad2Pyth -> setFixedSize(ButtonSize);
    40. Quad2Pyth -> setStyleSheet("background-image: url(Buttons/P.png)");
    41.  
    42.  
    43.  
    44.  
    45. QPushButton *Quad2Sim = new QPushButton;
    46. Quad2Sim -> setFixedSize(ButtonSize);
    47. Quad2Sim -> setStyleSheet("background-image: url(Buttons/S.png)");
    48.  
    49.  
    50.  
    51. QPushButton *Quad22D = new QPushButton;
    52. Quad22D -> setFixedSize(ButtonSize);
    53. Quad22D -> setStyleSheet("background-image: url(Buttons/2.png)");
    54.  
    55.  
    56.  
    57.  
    58. QPushButton *Quad23D = new QPushButton;
    59. Quad23D -> setFixedSize(ButtonSize);
    60. Quad23D -> setStyleSheet("background-image: url(Buttons/3.png)");
    61.  
    62.  
    63. QSpacerItem *Spacer0001 = new QSpacerItem(100, 450, QSizePolicy::Ignored, QSizePolicy::Ignored);
    64.  
    65.  
    66.  
    67.  
    68. QGridLayout *QuadLayout = new QGridLayout;
    69. QuadLayout -> addItem(Spacer0001,1,1,1,1,Qt::AlignLeft);
    70. QuadLayout -> addWidget(Quad2Menu,3,1,1,1,Qt::AlignLeft);
    71. QuadLayout -> addWidget(Quad2Quad,4,1,1,1,Qt::AlignLeft);
    72. QuadLayout -> addWidget(Quad2Pyth,5,1,1,1,Qt::AlignLeft);
    73. QuadLayout -> addWidget(Quad2Trig,6,1,1,1,Qt::AlignLeft);
    74. QuadLayout -> addWidget(Quad2Sim,7,1,1,1,Qt::AlignLeft);
    75. QuadLayout -> addWidget(Quad22D,8,1,1,1,Qt::AlignLeft);
    76. QuadLayout -> addWidget(Quad23D,9,1,1,1,Qt::AlignLeft);
    77. Quad -> setLayout(QuadLayout);
    78.  
    79.  
    80.  
    81. Quad -> show();
    82.  
    83.  
    84.  
    85. }
    86.  
    87. void Quadratic::Quad2MenuClicked()
    88. {
    89. MainMenu w;
    90. }
    To copy to clipboard, switch view to plain text mode 


    The compiler does not give me any errors, so im confused to why the first button would work but the second one doesnt.
    Also, I have tried running the QUAD widget first instead of the MainMenu. The result was that again the first button worked, but then the second didnt (basically the same just in reverse)

    Any help is much appreciated!

    P.s Incase it is not clear, my wish is to firstly open up MainMenu (Works) then click a button to open Quad (works) but then from Quad, return to Main Menu using another button (doesnt work)
    Last edited by Jake123; 22nd January 2013 at 17:12.

Similar Threads

  1. Problem with connect
    By Momergil in forum Newbie
    Replies: 8
    Last Post: 29th July 2011, 01:27
  2. Problem with connect
    By eekhoorn12 in forum Newbie
    Replies: 3
    Last Post: 21st December 2010, 20:48
  3. connect() problem
    By harmodrew in forum Newbie
    Replies: 14
    Last Post: 5th August 2010, 17:45
  4. connect problem
    By liengen in forum Newbie
    Replies: 2
    Last Post: 22nd October 2008, 16:21
  5. Problem with connect()
    By mrnor3 in forum Qt Programming
    Replies: 3
    Last Post: 23rd July 2008, 14: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.