Results 1 to 7 of 7

Thread: A bug of QLayout

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Posts
    11
    Thanks
    1

    Default A bug of QLayout ?

    Hi,
    I just find a assert failure when I use QLayout. I want know is this a bug of QLayout.
    The QLayout has a constructor like this, which need a parent of QWdiget
    Qt Code:
    1. QLayout::QLayoutQWidget *parent)
    2. : QObject(*new QLayoutPrivate, parent)
    3. {
    4. if (!parent)
    5. return;
    6. parent->setLayout(this);
    7. }
    To copy to clipboard, switch view to plain text mode 

    But in the code of QLayout:arentWidget() (line 6), it trys to cast the parent to QLayout
    Qt Code:
    1. QWidget *QLayout::parentWidget() const
    2. {
    3. Q_D(const QLayout);
    4. if (!d->topLevel) {
    5. if (parent()) {
    6. QLayout *parentLayout = ::qobject_cast<QLayout*>(parent());
    7. Q_ASSERT(parentLayout);
    8. return parentLayout->parentWidget();
    9. } else {
    10. return 0;
    11. }
    12. } else {
    13. Q_ASSERT(parent() && parent()->isWidgetType());
    14. return static_cast<QWidget *>(parent());
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 

    certainly, cast from QWidget* to QLayout* will failled, and the successed assertion will failed. Is this a bug or anything I don't know?
    Thanks for your help!
    Last edited by cocalele; 24th April 2006 at 07:25.

Similar Threads

  1. whether Qcanvas objects be added in QLayout
    By Amrita Singh in forum Newbie
    Replies: 1
    Last Post: 25th February 2009, 09:55
  2. QLayout: different SizeConstraints for width and height?
    By PhilippB in forum Qt Programming
    Replies: 0
    Last Post: 23rd February 2009, 16:33
  3. QLayout on hidden window
    By benacler in forum Qt Programming
    Replies: 0
    Last Post: 2nd September 2008, 18:04
  4. QLayout update size signal
    By bunjee in forum Qt Programming
    Replies: 3
    Last Post: 6th June 2008, 11:24
  5. custom QLayout help
    By Micawber in forum Qt Programming
    Replies: 2
    Last Post: 19th October 2007, 21:44

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.