Results 1 to 4 of 4

Thread: QDialog problem when setting mainwindow as parent

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2011
    Posts
    42
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QDialog problem when setting mainwindow as parent

    We have a mainwindow class that inherits from QMainWindow. We use this flags:
    Qt Code:
    1. setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
    To copy to clipboard, switch view to plain text mode 

    Before starting the aplication we display a QDialog with some text. If we create this QDialog with the mainwindow as the parent, some weird things happen when animating de mainwindow.

    At some point in the program we need to expand down the mainwindow to show a progressbar. When doing this, misteriously the mainwindow gets expanded down, but it also losses width. Each time we expand it down, the width decreses. This behaviour ONLY happens when creating the QDialog with mainwindow as parent, if using parent NULL, evertyhing works fine.

    Qt Code:
    1. QDialog* eulaWin = new QDialog(this, Qt::Dialog | Qt::Window | Qt::WindowStaysOnTopHint );
    To copy to clipboard, switch view to plain text mode 

    and this is the expand method in the custom utility class for animations:
    (expand down => FX_DOWN)
    Qt Code:
    1. void FXManager::expand(QWidget *widget, int direction, int speed, int ratio, QEasingCurve easingCurve)
    2. {
    3. QPropertyAnimation* animationFrame = new QPropertyAnimation(widget, "geometry", widget);
    4.  
    5. animationFrame->setDuration(speed);
    6. animationFrame->setEasingCurve(easingCurve);
    7.  
    8. animationFrame->setStartValue(QRect(widget->geometry().x(),widget->geometry().y(), widget->geometry().width(), widget->geometry().height()));
    9.  
    10. switch(direction)
    11. {
    12. case (int)FX_LEFT: animationFrame->setEndValue(QRect(widget->geometry().x() - ratio,widget->geometry().y()+0, widget->geometry().width() + ratio, widget->geometry().height()));
    13. break;
    14. case (int)FX_RIGHT: animationFrame->setEndValue(QRect(widget->geometry().x()+0,widget->geometry().y()+0, widget->geometry().width() + ratio, widget->geometry().height()));
    15. break;
    16. case (int)FX_UP: animationFrame->setEndValue(QRect(widget->geometry().x()+0,widget->geometry().y() - ratio, widget->geometry().width(), widget->geometry().height() + ratio));
    17. break;
    18. case (int)FX_DOWN: animationFrame->setEndValue(QRect(widget->geometry().x()+0,widget->geometry().y()+0, widget->geometry().width(), widget->geometry().height() + ratio));
    19. break;
    20. }
    21.  
    22. animationFrame->start(QPropertyAnimation::DeleteWhenStopped);
    23.  
    24. widget->repaint();
    25. QApplication::processEvents();
    26. }
    To copy to clipboard, switch view to plain text mode 

    The basic idea if the expand method is to expand down (or in any direction choosed) as many pixels as specified in the ratio param. Thus we maintain the original position and width.

    Any ideas why this could be happening?
    Last edited by superpacko; 20th July 2011 at 15:51. Reason: spelling corrections

Similar Threads

  1. Replies: 2
    Last Post: 24th January 2010, 12:46
  2. SETTING THE TEXT COLOR FOR QMessageBox
    By vinkakarun in forum Newbie
    Replies: 2
    Last Post: 5th November 2009, 16:32
  3. setting background color of QMessageBox
    By wagmare in forum Qt Programming
    Replies: 7
    Last Post: 23rd May 2009, 13:26
  4. MainWindow disappearing when loading a QMessageBox
    By fabietto in forum Qt Programming
    Replies: 14
    Last Post: 25th June 2008, 23:41
  5. Setting QMessageBox geometry
    By Krish_ng in forum Qt Programming
    Replies: 3
    Last Post: 25th July 2007, 14:47

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.