Putting the 'role' back in role-playing games since 2002.
Donate to Codex
Good Old Games
  • Welcome to rpgcodex.net, a site dedicated to discussing computer based role-playing games in a free and open fashion. We're less strict than other forums, but please refer to the rules.

    "This message is awaiting moderator approval": All new users must pass through our moderation queue before they will be able to post normally. Until your account has "passed" your posts will only be visible to yourself (and moderators) until they are approved. Give us a week to get around to approving / deleting / ignoring your mundane opinion on crap before hassling us about it. Once you have passed the moderation period (think of it as a test), you will be able to post normally, just like all the other retards.

Qt\QtQuick Tutorial

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,561
Location
Tampon Bay
The problem is not performance but that the include fails.

#include <QMediaPlayer>

C1083: "QMediaPlayer": No such file or directory

I put this to the .pro file (also tried variants)

CONFIG += mobility
MOBILITY += multimedia

The same happens with all classes from QtMobility. I could try one last time by downloading and installing it, but according to all sources it should have been included in the SDK. I already wasted to much time with the solutions.
Gonna wait for for the next SDK release to try video playback again.
 

tiagocc0

Arcane
Joined
Jun 29, 2007
Messages
2,056
Location
Brazil
The problem is not performance but that the include fails.

#include <QMediaPlayer>

C1083: "QMediaPlayer": No such file or directory

I put this to the .pro file (also tried variants)

CONFIG += mobility
MOBILITY += multimedia

The same happens with all classes from QtMobility. I could try one last time by downloading and installing it, but according to all sources it should have been included in the SDK. I already wasted to much time with the solutions.
Gonna wait for for the next SDK release to try video playback again.

Ok. ;)
 

Hirato

Purse-Owner
Patron
Joined
Oct 16, 2010
Messages
3,930
Location
Australia
Codex 2012 Codex USB, 2014 Shadorwun: Hong Kong
QtMultimedia appears to have QVideoFrame class, why not have a quick look at that?
As far as I can tell there is no "QMediaPlayer"

As tiagocc0 mentioned, you might have more luck by otherwise using phonon for whatever you're doing.
I'd imagine that would ship with any given version of the Qt 4.x series...
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,561
Location
Tampon Bay
Can anyone explain the nitty gritty of the LGPL 2.1 license? So far my understanding is that I must not release source code for my application, and don't need to purchase a qt license, provided that I do not statically link to the libraries?

To be absolutely sure, I also need a definite explanation on static / dynamic linking. So far I assume dynamic linking is not configured by default, and a library is dynamically linked as long as the compiler produces no .obj files for anything (except my own classes).

I know this may sound noobish, but I only know how to do minimal configuration, and want to know if the default configuration is already compliant with the LGPL.
 

tiagocc0

Arcane
Joined
Jun 29, 2007
Messages
2,056
Location
Brazil
I'm a noob at it too, but this is what I understood about it.
Static linking means you are putting all code inside your exe. It gets bigger and doesn't need DLLs, it's easier to deploy but you have to have the source code. It's an grey area but people advise to not link statically unless you know for sure you can.
Dynamic is the default, you need to use DLLs, most people agree you can dynamic link without having to worry, so if you want to use LGPL you just need to download and use Qt.

LGPL protects Nokia as in if you change Qt source code you have to open this modification to Nokia and to anyone who uses your software, that's because you would be using a modified DLL so you have to inform people that's the case and provide them a way to update the DLL.
For example, you use QtGui.DLL, if Qt gets updated then the user has a choice of updating the QtGui.DLL to it's latest version. But if you have modified the Qt GUI module, then the QtGui.DLL that you use can't be updated. That's why you provide the source code, if someone wants to update it, it's still possible. And if Nokia likes your modification it can add to it's own source code.

Anyway, just don't modify the Qt source code. But even if you do and have to open the modified code, I think the rest of your code doesn't need to be open.

LGPL was made so it could be used in commercial software while still protecting the libraries.
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,561
Location
Tampon Bay
Thanks, that's how I understand it, too. But it could be more complicated.

I never planned on modifying qt, so for now I'll stick to the noobish interpretation that it means you can use the library for free, provided you don't use static linking.

But I don't think you can simply replace the dlls with newer versions, or doesn't stuff sometimes get deprecated / unsupported after the update?

Anyway, so far deployment has been a breeze, I just copy all the dlls, and it works fine on different computers / windows versions, that's something I really like about the whole system.
 

tiagocc0

Arcane
Joined
Jun 29, 2007
Messages
2,056
Location
Brazil
This thing about changing DLLs is a utopia, if libraries were made right and all problems related were solved this should be how things should be done.
The document is just ahead of it's time.

EDIT: But in linux I think this is done to some extent.
 

Hirato

Purse-Owner
Patron
Joined
Oct 16, 2010
Messages
3,930
Location
Australia
Codex 2012 Codex USB, 2014 Shadorwun: Hong Kong
True, there are plenty of deprecated and unsupported things in Qt4, but they're not queued for removal until Qt5 (Such as the Qt3 support).
So newer versions of the Qt library in the same series should work fine if just dropped in, excepting new bugs in components you use of course.
 

tiagocc0

Arcane
Joined
Jun 29, 2007
Messages
2,056
Location
Brazil
Yep, I had problems doing that with QtSql4.dll, other components usually behaved well for me.
But this might result in some hard to catch bugs that happens after quite a while of use.
 

tiagocc0

Arcane
Joined
Jun 29, 2007
Messages
2,056
Location
Brazil
Great, I'm testing the windows 8 beta so I will check if it works for it too.
Sorry for the delay, I just moved out and so I got no internet at home yet.
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,561
Location
Tampon Bay
Yeah, let me know how it worked out. What I understand is that Qt Creator uses debugging tools from the Microsoft SDK, that's why you need to install this stuff. I am sure there are other ways if you use another debugger/compiler.

For me it's working now, it's just a bit slow. I really need debugging, because I am testing data structures.

And if you should find out more about locating the required dlls, let me know, for some reasons I am too lazy, end up copying the complete Qt libraries, and it makes my release deployment very large (120MB).
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,561
Location
Tampon Bay
Very interesting, I just have too much overload right now to learn new tools.

I got some success by simply searching through the exe file. Most programs need QTGui4.dll and QtCore4.dll. I'll keep you updated on this approach.
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,561
Location
Tampon Bay
I am just hitting a wall with layouts. Apparently it is not possible to place a widget at an exact x,y position. In such cases you'd have to implement your own custom layout but there is practically no info available.

I think this is very bad for making games. As long as you cannot place widgets the way you want, and the custom layouts will always use some kind of horizontal and vertical stacking, it will not look like a game.

I spent a whole day trying to solve this problem and I've seen this questions asked by many people.
The answers always amount to:
- it's not possible
- you have to make you own layout (but no proper example)
- why do you want to do it, it is not recommended to do that, blah blah :lol:
 

J1M

Arcane
Joined
May 14, 2008
Messages
14,606
Add to a container that uses an absolute layout.

If you need more help with layouts feel free to summon me with the @ tag, but don't send PMs.
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,561
Location
Tampon Bay
J1M Thanks but what the hell is absolute layout?
Does this rectangle example help?
http://doc.qt.nokia.com/4.7/qml-item.html#x-prop

EDIT: Btw, I think you are right about it being bad for making games. :P

This example won't help me because I am not using QML, I do everything in code.

But perhaps I can ask you a more general question. Assuming you make a game and dynamically create buttons (at arbitrary x,y positions, and also have a QMenu attached, what would you use? Apart from that I want to do it as simple as possible.

So far I tried a normal QWidget with a Layout manager, where dynamically adding buttons works fine, but does not allow positioning. Then I tried QGraphicsView/QGraphicsScene which allows absolute positioning but everything else does not work (the menus are shown on the wrong place, disappear behind buttons, actions are not triggered).

What I don't understand is that this is the first environment where a simple button placement is such a problem. This no issue at all in C#, Java, even VBA can do it :lol:
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,561
Location
Tampon Bay
J1M

I can completely bypass Layout managers with

QPushButton *button = new QPushButton( *pointer to main widget* );

and

newButton->move(200,150);
newButton->setGeometry(50,50, 100, 100);

but that does not work when I create the button dynamically (at least nothing ever shows up).

Perhaps I could get away with creating all the buttons I will ever need in the constructor of my window and then, enable them with setVisible(). So far this is the only way I know how I could create buttons with contextmenus in a game window.
 

J1M

Arcane
Joined
May 14, 2008
Messages
14,606
I would make a parent container out of a QWidget or something for all of the items you want to go on the same layer (say UI). With them all inside a container, it will make it easier to position other types of controls above/below them. The Qt implementation I use at work is slightly different from the Nokia one. (We have an absolute layout, but I don't use it.)

I wouldn't normally use move() to position them because that will break if/when the resolution is different. Here is a tutorial on writing your own custom layout if you are really set on having complete control over it:
http://doc.qt.nokia.com/4.7/layout.html

A sketch of what you are going for would make suggesting a layout strategy easier.

But yes, I agree with you. Qt is focused on building a UI for a phone. For my own game I use XNA and have a custom layout system that allows you to specify things in terms of pixels, percentages, or font heights. You can mix and match them to say something like: put this control 50 pixels from the left and 14.44% from the top.
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,561
Location
Tampon Bay
I would make a parent container out of a QWidget or something for all of the items you want to go on the same layer (say UI). With them all inside a container, it will make it easier to position other types of controls above/below them. The Qt implementation I use at work is slightly different from the Nokia one. (We have an absolute layout, but I don't use it.)

I wouldn't normally use move() to position them because that will break if/when the resolution is different. Here is a tutorial on writing your own custom layout if you are really set on having complete control over it:
http://doc.qt.nokia.com/4.7/layout.html

I tried that before I posted, and that custom layout example does not even compile. I think I will try to use move() dynamically with pre instantiated buttons (luckily I know beforehand which buttons I will need, but not where they should be), parent the buttons directly to the widget (not a layout), and scale the coordinates according to the resolution. Layout managers are not that useful to me, because I will use fullscreen mode anyway, and I get more control if I resize every widget according to the resolution. This is not going to work only if the user changes the resolution while the program is running, but this seems a small problem to me.

Outside of the main menus I cannot simply paint buttons on the screen with QML, because screen content in the game is too interactive and dynamic.

A sketch of what you are going for would make suggesting a layout strategy easier.

It's a mission planning screen, supposed to look like a graph, with nodes connected to each other by lines or arcs, and the user can insert / add / remove nodes dynamically. Add possible scrolling/zooming and drag/drop to the equation and you should understand why QML is not useful to me.

But yes, I agree with you. Qt is focused on building a UI for a phone. For my own game I use XNA and have a custom layout system that allows you to specify things in terms of pixels, percentages, or font heights. You can mix and match them to say something like: put this control 50 pixels from the left and 14.44% from the top.

For a 2D game it should work, although the problems with positioning make scrollable interactive maps etc a LOT harder than I expected.
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,561
Location
Tampon Bay
I found a way that does in principle what I want to do. I already knew that I can bypass the need for using a predefined layout by setting the parent of the buttons to the form itself. But this was only working when I did it in the constructor of the main widget. When I want to create more buttons dynamically it is also necessary to call the show() method of the button, otherwise the button will never appear on the screen.

Take for example this keyPressEvent of a widget, it will create a new button every time the '1' key is pressed and place it at absolute coordinates:

void MissionPlanner::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_1)​
{​
index ++;​
QPushButton *newButton = new QPushButton(QString().setNum(index), this);​
newButton->setStyleSheet(buttonStyle);​
// now it's possible to place the button at absolute coordinate​
newButton->move(x, y);​
newButton->setFixedSize(w, h);​
// or: newButton->setGeometry(x, y, w, h);​
newButton->show();
}​
}
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,561
Location
Tampon Bay
But another question, did I understand it correctly that when I use a Q_OBJECT there is no need to delete the object? Take for example all these qt widgets that are created with new Qxxxx(). I must simply assume this, because in none of the examples destructors are used, so it must be handled automatically or the programs would leak badly.
 

As an Amazon Associate, rpgcodex.net earns from qualifying purchases.
Back
Top Bottom