Ox - Window Framework

Published May 05, 2012
[source lang="cpp"]

#include

#include "OxApplication.h"
#include "OxWidget.h"
#include "OxMainWindow.h"
#include "OxPushButton.h"

class Window : public Ox::MainWindow
{
public:
Window();

private:
void changeTitle(Object *sender){ setWindowTitle("Clicked!"); }

Ox::PushButton *button;
};

Window::Window()
{
button = new Ox::PushButton("Button", centralWidget());

connect(button->clicked, &Window::changeTitle);

resize(Ox::Size(300, 300));
setWindowTitle("Ox::Widget Test");
}

int WINAPI WinMain(HINSTANCE hIn, HINSTANCE, LPSTR cmdLine, int show)
{
Ox::Application app;

Window mainWindow;
app.connect(mainWindow.destroyed, &Ox::Application::exit);

mainWindow.show();

return app.exec();
}
[/source]

So my latest random for-fun project is the most infeasible yet - a Qt-inspired Win32 wrapper. It'll never work. It's stupid.

Most interesting part really is the reimplementation from scratch of the old type-safe signals/slots mechanism with templates. Quite happy with the syntax for connecting. Ox::Object under the hood maintains a list of Slot objects so that disconnection is automatic when the owing object goes out of scope.

The only annoyance is that I have to have Ox::Signal, Ox::Signal1, Ox::Signal2 etc. Be really nice if there was some way of just having Ox::Signal etc but I gather that isn't possible.

Not really a template metaprogrammer so quite pleased to have got it working anyway. Current stupid plan is to develop this to the point where its sort of vaguely working, then use it to re-write Opus, the 3D modeller, from scratch as I'm bored with the current version and want all the goodness I get from Qt at work without all the hassle of, y'know, actually having to use Qt.

Stupid plan, stupid project, stupid idea.
Previous Entry Template Metaprogramming
Next Entry Opus 3D revisited
0 likes 2 comments

Comments

Comments are shown oldest first so the discussion reads top to bottom.
Servant of the Lord
Qt is awesome, clean, neat, and powerful. The only probably with writing code in Qt is that it makes [i]your/my[/i] code anything [i]but[/i] clean, neat, and powerful. [img]http://public.gamedev.net//public/style_emoticons/default/laugh.png[/img]

Somehow, as neat and well-thoughtout the Qt libraries are, it always makes the parts of my code that use it feel cludgy and messy. Maybe I have trouble embracing Qt paradynes or something.

Your library is looking good!
May 05, 2012 07:01 PM
Aardvajk
Yeah, I kinda agree, although at work where cross-platform is an actual requirement rather than a buzzword as its used on the forums here, its pretty invaluable to be able to so easily stay within the Qt arena for pretty much everything.

My project is purely for fun. I don't ever expect it to be more than 1% Qt-feature complete but I'm hoping to start developing a project with it when the basics are working, then add to it as I go.
May 06, 2012 04:39 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!