Synchronized with trunk
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1151 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
commit
5978d015eb
24 changed files with 117 additions and 98 deletions
|
@ -3,10 +3,10 @@
|
|||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include "QSFMLCanvas.hpp"
|
||||
#include <Qt/qapplication.h>
|
||||
#include <Qt/qframe.h>
|
||||
#include <Qt/qlabel.h>
|
||||
#include <Qt/qevent.h>
|
||||
#include <QApplication>
|
||||
#include <QVBoxLayout>
|
||||
#include <QFrame>
|
||||
#include <QLabel>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -20,8 +20,8 @@ public :
|
|||
/// Construct the canvas
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
MyCanvas(QWidget* Parent, const QPoint& Position, const QSize& Size) :
|
||||
QSFMLCanvas(Parent, Position, Size)
|
||||
MyCanvas(QWidget* Parent = NULL) :
|
||||
QSFMLCanvas(QSize(100, 100), 0, Parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -56,6 +56,12 @@ private :
|
|||
{
|
||||
mySprite.SetPosition(ConvertCoords(Event.MouseMove.X, Event.MouseMove.Y));
|
||||
}
|
||||
|
||||
// Adjust the size of the default view when the widget is resized
|
||||
if (Event.Type == sf::Event::Resized)
|
||||
{
|
||||
GetDefaultView().SetRect(sf::FloatRect(0, 0, Event.Size.Width, Event.Size.Height));
|
||||
}
|
||||
}
|
||||
|
||||
// Rotate the sprite
|
||||
|
@ -94,13 +100,16 @@ int main(int argc, char **argv)
|
|||
|
||||
// Create a label for showing some text
|
||||
QLabel* Label = new QLabel("This is a SFML window\nembedded into a Qt frame :", MainFrame);
|
||||
Label->move(20, 10);
|
||||
Label->setFont(QFont("courier new", 14, 1, false));
|
||||
Label->show();
|
||||
|
||||
// Create a SFML view inside the main frame
|
||||
MyCanvas* SFMLView = new MyCanvas(MainFrame, QPoint(20, 60), QSize(360, 320));
|
||||
SFMLView->show();
|
||||
MyCanvas* SFMLView = new MyCanvas(MainFrame);
|
||||
|
||||
// Create the main layout
|
||||
QVBoxLayout* Layout = new QVBoxLayout;
|
||||
Layout->addWidget(Label, 0);
|
||||
Layout->addWidget(SFMLView, 1);
|
||||
MainFrame->setLayout(Layout);
|
||||
|
||||
return App.exec();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue