Ok, edited the question. Bolded the edited part.

@wysota : Mmmm, I'm not sure I understand what you are asking, but here is the complete code. I hope this helps.

mainwindow.cpp
Qt Code:
  1. mainwindow::mainwindow()
  2. {
  3.  
  4. #include <QtGui>
  5. #include <iostream>
  6. #include "mainwindow.h"
  7. #include "game.h"
  8. #include "menu1.h"
  9.  
  10. men = new menu1(this);
  11. qur = new game(this);
  12.  
  13. qs = new QStackedWidget(this);
  14. qs->resize(880,558);
  15. qs->addWidget(men);
  16. qs->addWidget(qur);
  17.  
  18. qs->setCurrentIndex(0);
  19.  
  20. show();
  21. }
To copy to clipboard, switch view to plain text mode 


menu1.cpp

Qt Code:
  1. #include "menu1.h"
  2. #include <QtGui>
  3.  
  4. menu1::menu1(QWidget *parent) :
  5. QWidget(parent)
  6. {
  7.  
  8. resize(880,558);
  9.  
  10. }
  11.  
  12. void menu1::paintEvent(QPaintEvent *)
  13. {
  14. QPainter painter(this);
  15. painter.setRenderHint(QPainter::Antialiasing, true);
  16. path.moveTo(qrand() % 80, qrand() % 320);
  17. path.cubicTo(200, 200, 320, 80, 480, 320);
  18. painter.setPen(QPen(Qt::green, 8));
  19. painter.drawPath(path);
  20. }
To copy to clipboard, switch view to plain text mode