6obj->metaObject()->className();
8QPushButton::staticMetaObject.className();
13QPushButton::staticMetaObject.className();
16obj->metaObject()->className();
33timer->inherits(
"QTimer");
34timer->inherits(
"QObject");
35timer->inherits(
"QAbstractButton");
39layout->inherits(
"QObject");
40layout->inherits(
"QLayoutItem");
45qDebug(
"MyClass::setPrecision(): (%s) invalid precision %f",
46 qPrintable(objectName()), newPrecision);
65 textEdit =
new QTextEdit;
66 setCentralWidget(textEdit);
68 textEdit->installEventFilter(
this);
73 if (obj == textEdit) {
74 if (event->type() == QEvent::KeyPress) {
75 QKeyEvent *keyEvent =
static_cast<QKeyEvent*>(event);
76 qDebug() <<
"Ate key press" << keyEvent->key();
83 return QMainWindow::eventFilter(obj, event);
90myObject->moveToThread(QApplication::instance()->thread());
109 using namespace std::chrono_literals;
119 qDebug() <<
"Timer ID:" << event->id();
144monitoredObj->installEventFilter(filterObj);
160 if (event->type() == QEvent::KeyPress) {
161 QKeyEvent *keyEvent =
static_cast<QKeyEvent *>(event);
162 qDebug(
"Ate key press %d", keyEvent->key());
166 return QObject::eventFilter(obj, event);
177pushButton->installEventFilter(keyPressEater);
178listView->installEventFilter(keyPressEater);
185 QLabel *senderLabel =
new QLabel(tr(
"Name:"));
186 QLabel *recipientLabel =
new QLabel(tr(
"Name:",
"recipient"));
192if (receivers(SIGNAL(valueChanged(QByteArray))) > 0) {
194 get_the_value(&data);
195 emit valueChanged(data);
203QObject::connect(scrollBar, SIGNAL(valueChanged(
int)),
204 label, SLOT(setNum(
int)));
210QObject::connect(scrollBar, SIGNAL(valueChanged(
int value)),
211 label, SLOT(setNum(
int value)));
227 QPushButton *myButton;
232 myButton =
new QPushButton(
this);
233 connect(myButton, SIGNAL(clicked()),
234 this, SIGNAL(buttonClicked()));
240QObject::connect: Cannot queue arguments of type
'MyType'
241(Make sure
'MyType' is registered
using qRegisterMetaType().)
246disconnect(myObject,
nullptr,
nullptr,
nullptr);
251myObject->disconnect();
261myObject->disconnect(SIGNAL(mySignal()));
271myObject->disconnect(myReceiver);
276if (signal == QMetaMethod::fromSignal(&MyObject::valueChanged)) {
283void on_<object name>_<signal name>(<signal parameters>);
296 Q_CLASSINFO(
"Author",
"Pierre Gendron")
297 Q_CLASSINFO(
"URL",
"http://www.my-organization.qc.ca")
305Q_PROPERTY(QString title READ title WRITE setTitle USER
true)
310class MyClass :
public QObject
315 MyClass(QObject *parent =
nullptr);
318 enum Priority { High, Low, VeryHigh, VeryLow };
320 void setPriority(Priority priority);
321 Priority priority()
const;
327class QItemSelectionModel :
public QObject
342 SelectCurrent = Select | Current,
343 ToggleCurrent = Toggle | Current,
344 ClearAndSelect = Clear | Select
347 Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag)
348 Q_FLAG(SelectionFlags)
355QPushButton *
button = parentWidget->findChild<QPushButton *>(
"button1", Qt::FindDirectChildrenOnly);
360QListWidget *
list = parentWidget->findChild<QListWidget *>(Qt::FindDirectChildrenOnly);
371QObject::connect(lineEdit, &QLineEdit::textChanged,
372 label, &QLabel::setText);
378QObject::connect(button, &QPushButton::clicked, someFunction);
384socket->connectToHost(
"qt-project.org", 80);
385QObject::connect(socket, &QTcpSocket::connected, [=] () {
386 socket->write(
"GET " + page +
"\r\n");
391disconnect(myObject, &MyObject::mySignal(),
nullptr,
nullptr);
395QObject::disconnect(lineEdit, &QLineEdit::textChanged,
396 label, &QLabel::setText);
401if (isSignalConnected(valueChangedSignal)) {
403 data = get_the_value();
404 emit valueChanged(data);
411QObject::connect(button, &QPushButton::clicked,
this, someFunction, Qt::QueuedConnection);
417socket->connectToHost(
"qt-project.org", 80);
418QObject::connect(socket, &QTcpSocket::connected,
this, [=] () {
419 socket->write(
"GET " + page +
"\r\n");
420 }, Qt::AutoConnection);
424class MyClass :
public QWidget
429 MyClass(QWidget *parent =
nullptr);
432 bool event(QEvent* ev) override
434 if (ev->type() == QEvent::PolishRequest) {
438 }
else if (ev->type() == QEvent::Show) {
445 return QWidget::event(ev);
453const QSignalBlocker blocker(someQObject);
461someQObject->blockSignals(wasBlocked);
468 const auto id = Qt::TimerId{obj->startTimer(100ms)};
469 if (id != Qt::TimerId::Invalid)
bool eventFilter(QObject *obj, QEvent *ev) override
Filters events if this object has been installed as an event filter for the watched object.
void timerEvent(QTimerEvent *event) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
qDebug("Items in list: %d", myList.size())
[23]
const bool wasBlocked
[52]
static const QMetaMethod valueChangedSignal
[48]
QAbstractButton * button
[8]
void on_button1_clicked()
[33]
disconnect(myObject, SIGNAL(mySignal()), nullptr, nullptr)
[27]
QList< QWidget * > widgets
[11]
KeyPressEater * keyPressEater
[15]
QList< QPushButton * > allPButtons
[12]
QList< QPushButton * > childButtons
[42]