Results 1 to 6 of 6

Thread: Custom Widget inside a QVboxLayout

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: Custom Widget inside a QVboxLayout

    Quote Originally Posted by nemesis View Post
    Yes, If I use standard widgets I can see all of them!
    Hmm... What are the values of sizePolicy and minimumSize properties?

  2. #2
    Join Date
    Jun 2008
    Posts
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Custom Widget inside a QVboxLayout

    I have solved the problem!!!

    Here was the code before I fixed it:

    Qt Code:
    1. QWidget* privateLayoutWidget = new QWidget( this, "layout2" );
    2. privateLayoutWidget->setGeometry( QRect( 0, 0, 642, 400 ) );
    3. layout2 = new QVBoxLayout( privateLayoutWidget, 11, 6, "layout2");
    4.  
    5. textLabel3 = new QLabel( privateLayoutWidget, "textLabel3" );
    6. textLabel3->setMinimumSize( QSize( 640, 16 ) );
    7. textLabel3->setAlignment( int( QLabel::AlignCenter ) );
    8. layout2->addWidget( textLabel3 );
    9.  
    10. plt = new plotter();
    11. layout2->addWidget( plt);
    To copy to clipboard, switch view to plain text mode 

    I did not set the parent when I created the plotter instance.
    I corrected this code to:

    Qt Code:
    1. QWidget* privateLayoutWidget = new QWidget( this, "layout2" );
    2. privateLayoutWidget->setGeometry( QRect( 0, 0, 642, 400 ) );
    3. layout2 = new QVBoxLayout( privateLayoutWidget, 11, 6, "layout2");
    4.  
    5. textLabel3 = new QLabel( privateLayoutWidget, "textLabel3" );
    6. textLabel3->setMinimumSize( QSize( 640, 16 ) );
    7. textLabel3->setAlignment( int( QLabel::AlignCenter ) );
    8. layout2->addWidget( textLabel3 );
    9.  
    10. plt = new plotter(privateLayoutWidget);
    11. plt->setMinimumSize(640,200);
    12. layout2->addWidget( plt);
    To copy to clipboard, switch view to plain text mode 

    And now it works!
    I'm reading some texts to know why is it necessary to specify the parent widget...

    Thanks a lot!

Similar Threads

  1. Custom Widget - First Steps
    By sekatsim in forum Qt Programming
    Replies: 8
    Last Post: 26th June 2008, 17:19
  2. Replies: 5
    Last Post: 25th May 2008, 08:22
  3. Replies: 3
    Last Post: 17th March 2008, 19:54
  4. Custom widget
    By zorro68 in forum Qt Programming
    Replies: 7
    Last Post: 28th January 2008, 14:06
  5. custom plug-in widget in another custom plug-in widget.
    By MrGarbage in forum Qt Programming
    Replies: 6
    Last Post: 27th August 2007, 15:38

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