Hello everybody,
I tried to make a little Wrapper-Class for the QPushButton, where I need to gather the Signal clicked() from the Button and rout it to a new written slot called "DoCommand()".
But this slot is never called by the Button's clicked() signal.
The compiler, linker run well. The Application itself runs "well", so without this functionality I told^^
Here is the Headerfile:
#pragma once
#include <QtGui\qpushbutton.h>
{
Q_OBJECT
public:
MenuButton(std::string &title);
~MenuButton()
{
//delete pButton;
}
std::string command;
public slots:
void DoCommand(void);
};
#pragma once
#include <QtGui\qpushbutton.h>
class MenuButton : QObject
{
Q_OBJECT
public:
MenuButton(std::string &title);
~MenuButton()
{
//delete pButton;
}
std::string command;
QPushButton *pButton;
public slots:
void DoCommand(void);
};
To copy to clipboard, switch view to plain text mode
And here the soure file:
#include "MenuButton.h"
#include "../Kernel/ActionHandler.h"
MenuButton
::MenuButton(std
::string &title
) : QObject(){
pButton->setFixedSize(80, 45);
//QAction *action = new QAction(title.c_str(), this);
//action->connect(action, SIGNAL(triggered), this, SLOT(Clicked()));
//pButton->addAction(action);
bool success
= QObject::connect(pButton,
SIGNAL(clicked
()),
this,
SLOT(DoCommand
()));
Q_UNUSED(success);
Q_ASSERT(success);
}
void MenuButton::DoCommand(void)
{
LocalActionHandler->DoScript(command);
LocalActionHandler
->DoScript
(QString("print \"DoCommand was called\""));
}
#include "MenuButton.h"
#include "../Kernel/ActionHandler.h"
MenuButton::MenuButton(std::string &title) : QObject()
{
pButton = new QPushButton(title.c_str());
pButton->setFixedSize(80, 45);
//QAction *action = new QAction(title.c_str(), this);
//action->connect(action, SIGNAL(triggered), this, SLOT(Clicked()));
//pButton->addAction(action);
bool success = QObject::connect(pButton, SIGNAL(clicked()), this, SLOT(DoCommand()));
Q_UNUSED(success);
Q_ASSERT(success);
}
void MenuButton::DoCommand(void)
{
LocalActionHandler->DoScript(command);
LocalActionHandler->DoScript(QString("print \"DoCommand was called\""));
}
To copy to clipboard, switch view to plain text mode
Ehm, I forgott to say: success is always true in this case.
When I used an other slot from an other class' instance, for testing, everything worked well.
Does someone know what could be wrong ?
Maybe I made an stupid mistake anywhere..
Thanks a lot,
Matthias
Bookmarks