Results 1 to 5 of 5

Thread: Switching static to dynamic ui loading

  1. #1
    Join Date
    Jun 2006
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Switching static to dynamic ui loading

    I've been experimenting with the designer to create basic layouts (QWidget forms).

    Static versions of the code create a class and you yourself pass a QWidget to setupUi that it directly builds into (i.e. it does not create the toplevel holding widget). The passed in widget to be used as the toplevel can be subclassed to perform various things.

    Now switching to dynamic loading you hit a problem. Although I can again pass my subclassed widget to QuiLoader::load it does not directly create it in that object like before. Instead it creates an intermediate object, which is returned by the call. As a result the subclassing does not work and things do not work as before.

    Is there away of being able to dynamically load straight into the passed in QWidget without the creation of this other object?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [QT4] Switching static to dynamic ui loading

    The problem is that there is no way in C++ to initialize member variables, so that they point to corresponding widgets on the form (without generating additional code) or to create an object with specific member variables on the fly.

    Although you can still use the subclassing approach --- see the Calculator Builder example for possible solution.

  3. #3
    Join Date
    Jun 2006
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: [QT4] Switching static to dynamic ui loading

    > The problem is that there is no way in C++ to initialize member variables, so that they point to
    > corresponding widgets on the form (without generating additional code) or to create an object with
    > specific member variables on the fly.

    Thankyou for the response. Am not trying to repeat myself, so sorry if it seems like it. Going back to the static implementation it appears that the class providing setupUi takes a "pre-created" QWidget object and builds straight into it. setupUi directly modifies that passed in object. Thats all I want to happen with the dynamic loading but thats appears not to be the case with GuiLoader::load.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [QT4] Switching static to dynamic ui loading

    Quote Originally Posted by s_a_white
    it appears that the class providing setupUi takes a "pre-created" QWidget object and builds straight into it. setupUi directly modifies that passed in object. Thats all I want to happen with the dynamic loading but thats appears not to be the case with GuiLoader::load.
    Unfortunately you can't make QUiLoader behave differently (unless you convince the Trolls to change it). You could try to transfer all child widgets and a top-level layout to that existing widget, but I think it's not worth it.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Switching static to dynamic ui loading


Similar Threads

  1. static & dynamic linking
    By mickey in forum General Programming
    Replies: 6
    Last Post: 11th June 2010, 08:57
  2. Qt libs static and dynamic
    By conexion2000 in forum Installation and Deployment
    Replies: 3
    Last Post: 24th May 2006, 09:09

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.