[Qt] Please add qt_mac_set_dock_menu

Den Jean Den.Jean at telenet.be
Fri Sep 21 21:12:39 CEST 2007


On Thursday 20 September 2007 23:18:36 Felipe Monteiro de Carvalho wrote:
> Hello,
> it's necessary to use a platform specific function present in Qt and
> called qt_mac_set_dock_menu
>
> I couldn't find documentation for this functions (where are the docs

The first google result is the doc:
http://doc.trolltech.com/4.3/exportedfunctions.html

> for loose functions??), so I don't know since when it is available. If
> it's available at least since 4.2, it would be nice to have it added
> =)
>
> No hurry, you can wait for more requests before adding this. I just
> thougth I would comment this here so I don't forget about this.
>
> I asked on a Qt forum but I couldn't find any other way to make the
> dock menu respond to user commands. (There is a Quit menu there, so
> the user should expect to see the app quit when he presses it).
>
> http://doc.trolltech.com/qq/qq18-macfeatures.html#newlooks
>
> "It has always been possible to change the icon on the dock by using
> QApplication::setIcon(). It is now also possible to set a QMenu for
> the dock icon as well. This is available through a C++ function, but
> is not in a header, so you need to extern it yourself.
>
>     QMenu *menu = new QMenu;
>     // Add actions to the menu
>     // Connect them to slots
>     ...
>     extern void qt_mac_set_dock_menu(QMenu *);
>     qt_mac_set_dock_menu(menu);"

Now I know how you know the function name without googling :-)
This also shows the use: declare it (not present in header) and use it.
Just do the same in your in code like this:

procedure qt_x11_wait_for_window_manager(widget : QWidgetH); cdecl; 
external 'libQtGui.so' name '_Z30qt_x11_wait_for_window_managerP7QWidget';

I used an X11 function as I cannot test an Mac only function.

My generator parses classes and their methods. It does not expect 
flat methods like these. So this would be some manual work. 
This will also remove the name mangling.

Sample exercise:
==========

somewhere.h:
// Export without mangling (different name, otherwise compiler got crazy,camel 
casing in pascal makes it readable again)
C_EXPORT void qtx11waitforwindowmanager(QWidgetH handle);

somewhere.cpp:
// declare, because not present in header
void qt_x11_wait_for_window_manager(QWidget *widget);

// implement 
void qtx11waitforwindowmanager(QWidgetH handle) {
  qt_x11_wait_for_window_manager((QWidget *)handle);
}

qt4.pas: (camel casing :-)
procedure QtX11WaitForWindowManager(widget : QWidgetH); cdecl; external QtIntf 
name 'qtx11waitforwindowmanager';
                       

I will see when I have time for your mac function and where I can put that 
function.

regards,

Den Jean






More information about the Qt mailing list