Answer the question
In order to leave comments, you need to log in
Qt custom controls. How to create properties?
I want to create a custom button that will have an additional digit field.
digitbutton.h
#ifndef DIGITBUTTON_H
#define DIGITBUTTON_H
#include <QPushButton>
class DigitButton : public QPushButton
{
Q_OBJECT
Q_PROPERTY(int digit MEMBER m_digit)
public:
DigitButton(QWidget *parent = nullptr);
private:
int m_digit;
};
#endif // DIGITBUTTON_H
#include "digitbutton.h"
DigitButton::DigitButton(QWidget *parent) : QPushButton (parent)
{
}
Answer the question
In order to leave comments, you need to log in
In order for your class to appear in the designer, you need to write a plugin for the designer that will display it there.
In the Qt documentation, everything is pretty detailed.
You can start with this example doc.qt.io/qt-5/qtdesigner-customwidgetplugin-examp...
well, follow the links.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question