Results 1 to 11 of 11

Thread: Custom dialog

Hybrid View

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

    Default Re: Custom dialog

    here is an example with opacity animation (if I understand you correctly)
    Qt Code:
    1. void Test::setLabelOpacity(int opacity)
    2. {
    3. m_label->setWindowOpacity(opacity / 100.0);
    4. }
    5.  
    6. void Test::showLabel()
    7. {
    8. QPixmap pixmap(300, 300);
    9. QPainter painter(&pixmap);
    10. QRectF rectangle(0.0, 0.0, 299.0, 299.0);
    11. painter.setBrush(Qt::red);
    12. painter.setPen(Qt::red);
    13. painter.drawRoundedRect(rectangle, 20.0, 15.0);
    14.  
    15. m_label = new QLabel();
    16. m_label->setMask(QBitmap(pixmap));
    17. m_label->setPixmap(pixmap);
    18. m_label->setAttribute(Qt::WA_DeleteOnClose);
    19.  
    20.  
    21. QTimeLine *timeLine = new QTimeLine(1000, this);
    22. timeLine->setCurveShape(QTimeLine::LinearCurve);
    23. timeLine->setFrameRange(0, 100);
    24. connect(timeLine, SIGNAL(frameChanged(int)), SLOT(setLabelOpacity(int)));
    25. timeLine->start();
    26.  
    27. m_label->setWindowOpacity(0);
    28. m_label->show();
    29. }
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

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

    simol (1st April 2009)

  3. #2
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 66 Times in 62 Posts

    Default Re: Custom dialog

    u can have closeEvent() of your custom dialog like this to achieve that:

    Qt Code:
    1. void CustomDialog::closeEvent(QCloseEvent *event)
    2. {
    3. QTimeLine *timeLine = new QTimeLine(1000, this);
    4. timeLine->setCurveShape(QTimeLine::LinearCurve);//u can change this curve shape to achieve different effects, read QTimeLine
    5. timeLine->setFrameRange(0, 100);
    6. connect(timeLine, SIGNAL(frameChanged(int)),this, SLOT(setLabelOpacity(int)));
    7. connect(timeLine, SIGNAL(finished()),el, SLOT(quit()));
    8. timeLine->start();
    9. el.exec();
    10. QDialog::closeEvent(event);
    11. }
    12.  
    13. void CustomDialog::setLabelOpacity(int opacity)
    14. {
    15. setWindowOpacity(opacity / 100.0);
    16. }
    To copy to clipboard, switch view to plain text mode 

    i havent tested it but it should work

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

    Default Re: Custom dialog

    yup, that will pretty cool.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #4
    Join Date
    Mar 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    4

    Default Re: Custom dialog

    Thanks guys, appreciate your help.

Similar Threads

  1. Issue with Modelless dialog on Mac
    By Satyanarayana Chebrolu in forum Qt Programming
    Replies: 0
    Last Post: 24th February 2009, 10:10
  2. Replies: 9
    Last Post: 13th August 2008, 18:07
  3. Replies: 3
    Last Post: 18th October 2007, 08:07
  4. Resizing the dialog boxes
    By anju123 in forum Qt Programming
    Replies: 4
    Last Post: 14th September 2007, 10:41
  5. QGraphicsView: Dialog Position Doubt
    By arjunasd in forum Qt Programming
    Replies: 1
    Last Post: 6th August 2007, 17:48

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.