#include #include #include #include #include #include #include "window.h" #include "window.moc" #include "glwindow.h" Window::Window(QWidget* parent, const char* name ) : QWidget(parent,name) { QHBoxLayout *mainlayout = new QHBoxLayout(this,0,-1,"mainlayout"); // HBox layout will align all our widgets horizontally GLWindow* glWindow = new GLWindow( this, "GLWindow" ); //this-> its parent which is the main window "GLWindow"-> its name mainlayout->addWidget( glWindow ); // add it to the layout mainlayout->setStretchFactor( glWindow, 1 ); // tell it to stretch when possible to fill the window QVBoxLayout* buttons = new QVBoxLayout( mainlayout ); // VBox is horizonatlly aligned, this is a child of mainlayout, because it is going to be inside it. QPushButton* pauseButton = new QPushButton( "Pause", this ); connect( pauseButton, SIGNAL( clicked()), glWindow, SLOT( togglePaused())); buttons->addWidget( pauseButton, 0, Qt::AlignTop ); //pointer to widget, padding (ignore), alignment (found in class Qt). QLabel* label = new QLabel( "Num balls : 0", this ); // a label to show how many balls are bouncing around connect( glWindow, SIGNAL( numBallsChanged(const QString&)), label, SLOT( setText(const QString& ))); buttons->addWidget( label, 0, Qt::AlignTop ); buttons->insertStretch( -1, 1 ); //inserts blank spa QMenuBar* menubar = new QMenuBar( this ); QPopupMenu* file = new QPopupMenu( this ); file->insertItem("&Quit", qApp, SLOT(quit()), CTRL+ Key_D ); menubar->insertItem( "&File", file ); mainlayout->setMenuBar( menubar ); }