This works fine (maybe you forgot about Q_OBJECT?)
#include <QApplication>
#include <QPushButton>
#include <QLayout>
Q_OBJECT
public:
};
#include "main.moc"
int main(int argc, char **argv){
l->addWidget(new MyPushButton);
app.setStyleSheet(".MyPushButton{ border: 2px solid black; }");
w.show();
return app.exec();
}
#include <QApplication>
#include <QPushButton>
#include <QLayout>
class MyPushButton : public QPushButton {
Q_OBJECT
public:
MyPushButton(QWidget *parent=0) : QPushButton(parent){}
};
#include "main.moc"
int main(int argc, char **argv){
QApplication app(argc, argv);
QWidget w;
QVBoxLayout *l = new QVBoxLayout(&w);
l->addWidget(new MyPushButton);
l->addWidget(new QPushButton);
app.setStyleSheet(".MyPushButton{ border: 2px solid black; }");
w.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks