Ok hey guys, I have a very very weird bug. If I add the Q_OBJECT line to the class it makes it disappear. I have kept the class very small to show the bug. The class works like a charm when Q_OBJECT isn't present, but I need it to emit signals.
By disappear I mean that it doesn't show the class at all anymore on the UI, on the widget. It still somewhat works, because it creates a new window if I set the parent to NULL, indicating that the class is still somewhat operational.
rgcbutton.h
#ifndef RGCBUTTON_H
#define RGCBUTTON_H
#include <QWidget>
{
//Q_OBJECT
public:
~rgcbutton();
};
#endif // RGCBUTTON_H
#ifndef RGCBUTTON_H
#define RGCBUTTON_H
#include <QWidget>
class rgcbutton : public QWidget
{
//Q_OBJECT
public:
rgcbutton(QWidget *parent);
~rgcbutton();
};
#endif // RGCBUTTON_H
To copy to clipboard, switch view to plain text mode
rgcbutton.cpp
#include "rgcbutton.h"
#include <QMouseEvent>
{
QImage ximg; ximg.
load("skins/default/images/exit_inactive.png");
setStyleSheet("background-image: url(skins/default/images/exit_inactive.png);");
setFixedSize(ximg.size());
}
rgcbutton::~rgcbutton() { }
#include "rgcbutton.h"
#include <QMouseEvent>
rgcbutton::rgcbutton(QWidget *parent) : QWidget(parent)
{
QImage ximg; ximg.load("skins/default/images/exit_inactive.png");
setStyleSheet("background-image: url(skins/default/images/exit_inactive.png);");
setFixedSize(ximg.size());
}
rgcbutton::~rgcbutton() { }
To copy to clipboard, switch view to plain text mode
Implementation (Some random QWidget
login
::login(QWidget *parent
) : QWidget(parent, Qt
::FramelessWindowHint), ui
(new Ui
::login){
ui
->setupUi
(this); move
(QApplication::desktop()->geometry
().
center() - rect
().
center());
rgcbutton *TT = new rgcbutton(this);
TT->move(20, 20);
}
login::login(QWidget *parent) : QWidget(parent, Qt::FramelessWindowHint), ui(new Ui::login)
{
ui->setupUi(this); move(QApplication::desktop()->geometry().center() - rect().center());
rgcbutton *TT = new rgcbutton(this);
TT->move(20, 20);
}
To copy to clipboard, switch view to plain text mode
I'm stuck on this and I don't know what's happening. Your help is very much appreciated. This is the warning I get when I compile without Q_OBJECT. Maybe it helps: rgcbutton.h:0: Warning: No relevant classes found. No output generated.
Regards,
Sir Rogers
Bookmarks