I have a application that contains a KMainWindow which first calls setXMLFile() and then initializes a number of private vars which are of KAction type, each connected to a protected slot.
In these slots I just do a simple printf() to see if anything happens when I click the post in the menu. Well, something does happen, the problem is that all those printf()s all come after I close the application.
Here's the application:
test.h:
Code:
#include <kmainwindow.h>
#include <kaction.h>
class KAction;
class Test : public KMainWindow {
Q_OBJECT
public:
Test();
private:
KAction *a_mount;
KAction *a_upgrade;
KAction *a_settings;
protected slots:
void s_mount();
void s_upgrade();
void s_settings();
};
test.cpp
Code:
#include "test.h"
#include <qtabwidget.h>
#include <kmainwindow.h>
#include <kaction.h>
#include <stdio.h>
Test::Test() : KMainWindow(0, "Test") {
setXMLFile("testui.rc");
a_mount = new KAction(i18n("Mount"), 0, this, SLOT(s_mount()), actionCollection(), "mount");
a_upgrade = new KAction(i18n("Upgrade"), 0, this, SLOT(s_upgrade()), actionCollection(), "upgrade");
a_settings = new KAction(i18n("Settings"), 0, this, SLOT(s_settings()), actionCollection(), "settings");
QTabWidget *tab = new QTabWidget(this, "tab");
setCentralWidget(tab);
createGUI();
}
void Test::s_mount() { }
void Test::s_upgrade() { }
void Test::s_settings() {
printf("testing...\n");
}
I then run the application, everything looks good. I go to the menu and click on settings and nothing happens. But right after I close the window I get "testing..." in the terminal. So how can I make it execute the s_settings() while running, instead of waiting until it is terminating?