LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   kde programming (https://www.linuxquestions.org/questions/programming-9/kde-programming-258567/)

maldini1010 11-23-2004 07:29 PM

kde programming
 
Hi

I have created a GUI using kdevope 3 with kde libraries Now I want that when the users clicks the name in the menu bar(ie disconnect) the disconnectMe() function would be executed in my code.

I saw many examples on the net, but they all seem to use QT style connect & slot

Note: In order to insert the item I used

QPopupMenu *systemmenu = new QPopupMenu(this);
systemmenu->insertItem(i18n("Connect"),1);

where the 1 is just an index number.

Thanks alot
:)

rjlee 11-24-2004 03:47 AM

You do need to use Qt's connect and slot to do this, as far as I am aware.
libkde is built on top of libqt; the moc and everything else all work for KDE.

Basically, just add Q_OBJECT to the top of the declaration of the class, and instead of making the disconnectMe() method public: you should declare it as protected slot:

You will need to convert the .cpp file through moc, and then compile the .moc.cpp object along with the original .cpp; KDevelop will handle this for you if you re-run automake and friends for your project.

The alternative is to subclass the InsertItem class and re-implement the clicked() handler to call back the disconnectMe() method; but, being a slot, I don't know if that will work or not.

The connect() method is a lot easier to use in the long run.


All times are GMT -5. The time now is 12:14 PM.