I want a button to become invisible when I click on it. I'm inheriting from QPushButton and then promoting. I know the button is being created properly because when I put the setVisible part into the constructor, it works. It just doesn't work when I click on the button when the program is running, despite my attempt to override the QPushButton functions of click() or clicked(). What am I doing wrong here? How can I get this to work?
#ifndef SOUNDBUTTON_H
#define SOUNDBUTTON_H
#include <QPushButton>
{
public:
void click();
void clicked();
};
#endif // SOUNDBUTTON_H
// the cpp file
#include "soundbutton.h"
#include <stdio.h>
SoundButton
::SoundButton(QWidget *parent
){
printf("test me"); //doesn't output but not related to the problem
}
void SoundButton::click()
{
this->setVisible(false);
}
void SoundButton::clicked()
{
this->setVisible(false);
}
#ifndef SOUNDBUTTON_H
#define SOUNDBUTTON_H
#include <QPushButton>
class SoundButton : public QPushButton
{
public:
SoundButton(QWidget *parent = 0);
void click();
void clicked();
};
#endif // SOUNDBUTTON_H
// the cpp file
#include "soundbutton.h"
#include <stdio.h>
SoundButton::SoundButton(QWidget *parent)
: QPushButton(parent)
{
printf("test me"); //doesn't output but not related to the problem
}
void SoundButton::click()
{
this->setVisible(false);
}
void SoundButton::clicked()
{
this->setVisible(false);
}
To copy to clipboard, switch view to plain text mode
Bookmarks