I cannot connect KAction to slot on KMainWindow

I have a KMainWindow:

//file.h
class MainWindow: public KMainWindow {
public:
    MainWindow(QWidget *parent = 0);
...
...
...

private slots:
    void removeClick();

//file.cpp
MainWindow::MainWindow(QWidget *parent) :
KMainWindow(parent) {}

void MainWindow::removeClick() 
    {
    std::cout << "Remove" << std::endl;
    }

      

I can compile it correctly, but when I execute I get the message

Object::connect: No such slot KMainWindow::removeClick()

      

Can anyone help me?

0


source to share


2 answers


You forgot the Q_OBJECT macro.



class MainWindow: public KMainWindow 
{
    Q_OBJECT

public:
    // [snip]
}

      

+2


source


using KXmlGuiWindow instead of KMainWindow and Q_OBJECT macro



0


source







All Articles