Results 1 to 7 of 7

Thread: QLayoutPrivate issue

  1. #1
    Join Date
    Oct 2008
    Posts
    11
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question QLayoutPrivate issue

    I am trying to extend the Qt example FlowLayout to include the insertWidgetAt(int position, QWidget* w) method.

    I wrote (borrowed the code from QBoxLayout):

    Qt Code:
    1. //public:
    2. void FlowLayout::insertWidgetAt(int pos,QWidget *w){
    3. addChildWidget(w);
    4. insertItem(pos,QLayoutPrivate::createWidgetItem(this, w)); //***
    5. invalidate();
    6. }
    7.  
    8. //private:
    9. void FlowLayout::insertItem(int pos,QLayoutItem *item){
    10. itemList.insert(pos,item);
    11. }
    To copy to clipboard, switch view to plain text mode 

    At the line marked with //***, gcc gives "incomplete type `QLayoutPrivate' used in nested name specifier" error. What should I do to implement the method?

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QLayoutPrivate issue

    use QWidgetItem insted of QLayoutPrivate::createWidgetItem.
    i.e.
    Qt Code:
    1. insertItem(pos,QWidgetItem(w));
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. The following user says thank you to spirit for this useful post:

    gimel (26th November 2008)

  4. #3
    Join Date
    Oct 2008
    Posts
    11
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QLayoutPrivate issue

    I resolved this issue by

    Qt Code:
    1. #include <QtGui/private/qlayout_p.h>
    To copy to clipboard, switch view to plain text mode 

    If this will not work, I'll try your solution.

  5. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QLayoutPrivate issue

    it is bad idea to use Qt's internal code.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  6. #5
    Join Date
    Oct 2008
    Posts
    11
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QLayoutPrivate issue

    Indeed! Thank you.

  7. #6
    Join Date
    May 2011
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QLayoutPrivate issue

    I'm trying to do the exact same thing. This thread is rather old, but I would be very happy to know how you solved this. I'm struggling with getting the suggestion from "spirit" to work.

  8. #7
    Join Date
    May 2013
    Location
    Cambridge, UK
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QLayoutPrivate issue

    You also need to store the widget using addChildWidget(). So the additional functions should look like the following:

    Qt Code:
    1. void FlowLayout::insertItem(int index, QLayoutItem *item)
    2. {
    3. itemList.insert(index, item);
    4. }
    5.  
    6. void FlowLayout::insertWidget(int index, QWidget *widget)
    7. {
    8. addChildWidget(widget);
    9. QWidgetItem *item = new QWidgetItem(widget);
    10. insertItem(index, item);
    11. }
    To copy to clipboard, switch view to plain text mode 

    P.S. this works for me.

Similar Threads

  1. Replies: 1
    Last Post: 28th October 2008, 16:29
  2. deployment issue?
    By triperzonak in forum Installation and Deployment
    Replies: 1
    Last Post: 7th October 2008, 08:59
  3. qt4.4 pc specs requirements or qt3 support issue?
    By triperzonak in forum Installation and Deployment
    Replies: 0
    Last Post: 9th August 2008, 02:40
  4. qt3 to qt4 - uic issue
    By hvengel in forum Qt Programming
    Replies: 10
    Last Post: 4th March 2007, 02:59
  5. Replies: 5
    Last Post: 22nd September 2006, 08:04

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.