Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qobject_cast, trying to determine object class...
Forum Updated to NodeBB v4.3 + New Features

Qobject_cast, trying to determine object class...

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 394 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    Zerby
    wrote on 11 Mar 2014, 17:48 last edited by
    #1

    I have a MainWindow class, where in the eventFilter I have this:

    @
    ...
    case QEvent::ChildAdded:
    {
    QChildEvent ce =(QChildEvent)event;
    QObject *obj = ce->child();
    emit this->childAdded(obj);
    break;
    }
    ...@

    Then I have the childAdded signal connected to MainWindow::handleAddedObject(QObject *obj). Inside that I do:

    @
    baseWidget *w = qobject_cast<baseWidget *>(obj);
    if (w != 0) this->baseWidgetAdded(w);
    @

    Then I try it with:

    @
    MainWindow *w = new MainWindow();
    baseWidget *w1 = new baseWidget(w);
    @

    The handleAddedObject -function get called, but the qobject_cast returns 0 everytime. It must be the baseWidget w1 that triggers the function calls, because if I comment out the line where I create the baseWidget object, the handleAddedObject is not called at all. What am I doing wrong?

    1 Reply Last reply
    0

    1/1

    11 Mar 2014, 17:48

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved