Results 1 to 20 of 21

Thread: Extend the ui_xxx.h file

Hybrid View

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

    Default Re: Extend the ui_xxx.h file

    Is your form named "CalculatorForm" (check the objectName property)?

  2. #2
    Join Date
    Sep 2008
    Posts
    21
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Extend the ui_xxx.h file

    the .ui file is saved as calculatorform.ui and the objectName property is set to the value Form


    Regards

    Sajjad

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

    Default Re: Extend the ui_xxx.h file

    Quote Originally Posted by dosto.walla View Post
    the objectName property is set to the value Form
    In that case you have to use Ui::Form not Ui::CalculatorForm.

  4. #4
    Join Date
    Sep 2008
    Posts
    21
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Extend the ui_xxx.h file

    Thanks Jacek,

    Extending a component through the use of inheritance is functional.


    Now i have another issue regarding layout designing within Qt designer.

    I created a form widget and created some components(button, combo boxes)
    within the form and grouped them together in a grid layout.


    Then i inherit that class generated by qt compiler and incorporated a RenderArea class where i can draw different primitives.

    And creating another layout of grid layout type and then adding the render area as widget and the previous grid layout from the super class . The code snippet is as follows:


    ***************************''
    //create the layout
    QGridLayout *mainLayout = new QGridLayout;


    //add the render area and the items that have been
    //created with Qt Designer
    mainLayout->addWidget(renderArea,0,0);
    mainLayout->addLayout(ui.gridLayout,1,0);

    setLayout(mainLayout);


    *****************************''


    The code compiled fine. But while running having the following error:

    QLayout::addChildLayout: layout "gridLayout" already has a parent
    Segmentation fault



    Any Idea?


    Regards
    Sajjad

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

    Default Re: Extend the ui_xxx.h file

    If you want to add a widget to the layout created with Qt Designer, it is easier to use the widget promotion mechanism.

    http://doc.trolltech.com/4.4/designe...moting-widgets

  6. #6
    Join Date
    Sep 2008
    Posts
    21
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Extend the ui_xxx.h file

    Hello jacek,


    I have gone through the material that you have sent with the link.

    "To add a placeholder, select an object of a suitable base class and choose Promote to ... from the form's context menu. After entering the class name and header file in the lower part of the dialog, choose Add. The placeholder class will now appear along with the base class in the upper list. Click the Promote button to accept this choice."


    I did not understand exactly how do i do that. If you please take a look at the attached png file, you will see that a form with widgets already in the layout.


    What i want to do is :


    1. Create a main layout and add the layout that you see in the form to the main layout.

    2. Create the RenderArea that is the subclass of the QWidget and add that to the main layout.


    So in that case which one is the place-holder that i should promote to?

    While designing the form i have the form itself and the other widgets set in a grid layout , what is not there is the RenderArea and it is the subclass of QWidget and how do i choose the place-holder for the RenderArea and who would be the place-holder?


    Regards

    Sajjad
    Attached Images Attached Images

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

    Default Re: Extend the ui_xxx.h file

    Quote Originally Posted by dosto.walla View Post
    So in that case which one is the place-holder that i should promote to?
    If your custom class is derived from QWidget, then add a QWidget to your form and promote it.

  8. #8
    Join Date
    Sep 2008
    Posts
    21
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Extend the ui_xxx.h file

    Thanks jacek,

    Drag a QWidget within the Qt Designer and promoted it to the custom class that i have made.


    Now i have almost the same error:


    QLayout::addChildLayout: layout "gridLayout" already has a parent
    Segmentation fault

    Another forum said something related to that

    "If you want to create a sub-layout (i.e. you want to add it to another
    layout), then you have to create it WITHOUT a parent. Just use the
    constructor of QLayout without a parent.

    Only add a parent (namely the top widget) for a top level layout (i.e. the
    main layout of a widget).
    "

    How do i do that from within the Qt Designer?


    In my case the gridLayout is the sub layout. and i have to instantiate that without a parent.

    Regards
    Sajjad

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

    Default Re: Extend the ui_xxx.h file

    Quote Originally Posted by dosto.walla View Post
    QLayout::addChildLayout: layout "gridLayout" already has a parent
    The problem is that you try to add a layout to a form that already has a layout. Qt doesn't like this.

    Quote Originally Posted by dosto.walla View Post
    How do i do that from within the Qt Designer?
    Either drag a layout from the toolbox just as if it was a widget or select few widgets and click the "Lay out in ..." action (you should see a red rectangle around those widgets).

  10. The following user says thank you to jacek for this useful post:

    dosto.walla (15th September 2008)

  11. #10
    Join Date
    Sep 2008
    Posts
    21
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Extend the ui_xxx.h file

    Hello jacek,


    i am still having the same error. So i am attaching the related files.
    I hope that you can make some time out of your busy schedule.


    Regards
    Sajjad
    Attached Files Attached Files

  12. #11
    Join Date
    Sep 2008
    Posts
    21
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Extend the ui_xxx.h file

    Hello jacek,

    I have attached some screen-shots of the things you have recommended to do to avoid the error:

    The image that is attached first shows the following:

    1. All the toolbars that are arranged in a grid layout.

    2. The rectangle box beside that is a QWidget that i have dragged into the form.


    The second image shows how i promoted the custom class RenderArea.h to one of the place-holders(QWidget)

    The i compiled them ,but while running i have the runtime error as follows:

    QLayout::addChildLayout: layout "gridLayout" already has a parent
    Segmentation fault


    It says that the gridLayout already has a parent

    i followed you suggestion

    "Either drag a layout from the toolbox just as if it was a widget or select few widgets and click the "Lay out in ..." action (you should see a red rectangle around those widgets)."


    I followed the one in the bold mark. And you can see that in the attached images as well.


    Regards
    Sajjad
    Attached Images Attached Images

  13. #12
    Join Date
    Sep 2008
    Posts
    21
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Extend the ui_xxx.h file

    Hi jacek,

    Sorry that i could not attach the second image with the previous post

    Here i am sending the second image


    Regards
    Sajjad
    Attached Images Attached Images

Similar Threads

  1. Set up the Qt4.3.2 with Visual Studio 2005
    By lamoda in forum Installation and Deployment
    Replies: 6
    Last Post: 30th January 2008, 06:51
  2. file renaming on windows
    By jdd81 in forum Qt Programming
    Replies: 9
    Last Post: 2nd October 2007, 19:41
  3. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  4. Sending Binary File with QFTP
    By nbkhwjm in forum Newbie
    Replies: 2
    Last Post: 7th March 2007, 18:10
  5. QDirModel, Model/View, extend the file onfo
    By VlJE in forum Qt Programming
    Replies: 10
    Last Post: 11th December 2006, 10:56

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
  •  
Qt is a trademark of The Qt Company.