WxQt
Getting started
Go to your development directory and checkout the wxQT branch with:
svn checkout http://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxQT
this creates the wxQT directory in your development directory. If you want to work in a different named directory, then create your working directory first, change into it and call
svn checkout http://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxQT .
note the dot at the end of the command!
Now create the build directory e.g.: 'build_qt_debug' and from it call:
../configure --with-qt --enable-debug
Adding files
To add a Qt derived class simply put it in a .h file and add the corresponding .moc.cpp file to the buid/bakefiles/files.bkl e.g.:
<set var="QT_LOWLEVEL_HDR" hints="files">
wx/qt/menuitem.h
</set>
<set var="QT_LOWLEVEL_SRC" hints="files">
src/qt/menuitem.cpp
src/qt/menuitem.moc.cpp
</set>
Regenerate the autoconf files with:
bakefile_gen --formats autoconf
Generate the 'configure' script in your wxQt root directory with:
autoconf
The build rule in build/bakefiles/qtrules.mk:
$(srcdir)/src/qt/%.moc.cpp: $(srcdir)/include/wx/qt/%.h
moc $< -o $@
will then ensure that the .h file gets translated by the moc to a .moc.cpp file which will be compiled and linked like any other source file. You don't have to put it in a separate .h file, you can put it in the same header as the wx class, but you can't embed it in the .cpp file i.e.:
// include/wx/qt/menuitem.h
class wxMenuItem : public wxMenuItemBase
{
// ...
};
class wxQtAction : public QAction
{
Q_OBJECT
public:
wxQtAction( wxMenuItem *menuItem, const QString &text, QObject *parent );
private Q_SLOTS:
void OnActionTriggered( bool checked );
private:
wxMenuItem *m_menuItem;
};
Coding guidelines
- If you leave out an implementation for whatever reason, then mark it with the wxMISSING_IMPLEMENTATION() macro from wx/qt/utils.h i.e.:
void wxSomeClass::SomeMethod()
{
wxMISSING_IMPLEMENTATION( __FUNCTION__ );
}
or if only some implementation is missing like evaluating flags:
void wxSomeClass::SomeMethod( unsigned methodFlags )
{
wxMISSING_IMPLEMENTATION( "methodFlags" );
}
- To avoid name clashes with a 3rd party library like boost, don't use the internal moc keywords 'signals' and 'slots' but the replacements Q_SLOTS and Q_SIGNALS i.e.:
class wxQtClass : public QClass
{
private Q_SLOTS:
void OnSignal();
};
Naming conventions
- Global helper classes and global functions should be prefixed with 'wxQt' i.e.:
class wxQtButton : public QPushButton
{
}
QRect wxQtConvertRect( const wxRect & );
- Internal methods in publicly visible classes (like wxWindow) should be prefixed with 'Qt' i.e.:
class wxWindow : public wxWindowBase
{
public:
QWidget *QtGetContainer() const;
};
Port status
A table attempting to summarize progress in the port can be found at WxQt/Status.
I (Peter Most) can be contacted on the developer mailing list.