WxQt

From WxWiki
Jump to navigation Jump to search

Getting started

Go to your development directory and download the source code zip archive or checkout the current wxQT repository ("Google Summer of Code 2014" Qt branch) with:

git clone https://github.com/reingart/wxWidgets.git -b SOC2014_QT
cd wxWidgets

Now create the build directory e.g.: 'bldqt5' and from it call the configure script (using Qt option) and run make to start the compilation process:

mkdir bldqt5
cd bldqt5
../configure --with-qt --enable-debug
make

After successful build, you can go to the samples sub-directory, compile and run them, for example:

cd samples/controls
make
./controls

You can also try the tests and demos sub-directories.

Adding files

To add a Qt derived class simply put it in a .h file and add the corresponding .cpp file to the build/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
</set>

From within of the bakefiles directory, regenerate the autoconf files with:

bakefile_gen --formats autoconf

Generate the 'configure' script in your wxQt root directory with:

autoconf

IMPORTANT NOTE: The precompilation step (Qt's moc) is no more needed so the build rule was removed. There is no need to use Q_OBJECT nor Q_SLOTS macros.

// include/wx/qt/menuitem.h

class wxMenuItem : public wxMenuItemBase
{
   // ...
};



class wxQtAction : public QAction
{
public:
    wxQtAction( wxMenuItem *menuItem, const QString &text, QObject *parent );

private:
    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, and due precompilation step was removed, don't use the internal moc keywords 'signals' and 'slots':
class wxQtClass : public QClass
{
private:
    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.