Results 1 to 3 of 3

Thread: QObject->setParent() (sort of) freezes part of main interface.

  1. #1
    Join Date
    Apr 2011
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QObject->setParent() (sort of) freezes part of main interface.

    Hi folks!

    I'm having a problem with a Qt4/C++ app that I'm writing.

    I've created a custom class by subclassing QObject, in order for it to be able to use functions from my main application. I was hoping to use setParent to allow it to access my app's public functions via qobject_cast, which seems to work fine. However... while I have the QObject subclass's parent set as the main application, I can't click on, but can tab through 2 out of the three widgets on my main application. The other one I can click on and use absolutely fine. The others appear to work absolutely as expected, other than not being clickable.

    The whole application works absolutely fine if I don't use setParent, and don't try to access the main class's functions.

    Does anybody have a clue what on earth is going on here? I'm massively confused!

    Thanks in advance for any help guys!!

    X-T

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QObject->setParent() (sort of) freezes part of main interface.

    May be you can show some code,,,
    from what you said, may be setting the parent is passing the events to parent first and it ignores them..

  3. #3
    Join Date
    Apr 2011
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QObject->setParent() (sort of) freezes part of main interface.

    I've actually managed to sort it, thanks to going to copy and paste my subclass code here! Classic example of PEBKAC (Problem Exists Between Keyboard And Chair). I had apparently at some point changed my subclass to inherit from QWidget instead of QObject for some reason (I think because a QWidget's constructor optionally takes a parent argument). I changed it back to inherit from QObject, and now it works without fault! I'm assuming this is something to do with the differing ways in which QWidgets and QObjects handle events, as you say.

    Sorry to waste your time, my friend; I'll look at my code more carefully before posting next time!

    X-T

Similar Threads

  1. QObject::setParent across threads.
    By psih128 in forum Qt Programming
    Replies: 4
    Last Post: 21st January 2014, 16:01
  2. Main UI Freezes on QFileDilog is up
    By navi1084 in forum Qt Programming
    Replies: 4
    Last Post: 29th April 2010, 09:54
  3. Qt widget setParent
    By bunjee in forum Qt Programming
    Replies: 9
    Last Post: 30th November 2007, 20:38
  4. Replies: 6
    Last Post: 6th December 2006, 22:44
  5. Interface composition and QObject
    By brcain in forum Qt Programming
    Replies: 9
    Last Post: 20th November 2006, 17:56

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.