Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User ashwinbhatks's Avatar
    Join Date
    May 2010
    Posts
    16
    I want to display a MessageBox / Dialog with text "Hello World" for 2 seconds and then the message box must exit automatically without any user interaction.

    I tried with the following code but is not working. I still get an OK button which i have to press inorder to close the messagebox.

    QString lString("HelloWorld");
    QMessageBox lMessage(QMessageBox::Information, QString("HelloWorld"), (lString), MessageBox::NoButton, this);
    lMessage.setStyleSheet("background: gray");
    lMessage.exec();

    Thanks in advance for the answer.

  2. #2
    Registered User TimsonC2000's Avatar
    Join Date
    Apr 2009
    Posts
    32
    If I remember correctly on Desktop QMessagebox without a Button is a QDialog and this should be the same on other platforms.

  3. #3
    Registered User vikas44's Avatar
    Join Date
    Sep 2008
    Posts
    1
    Why don't you try startTimer(2000) // for 2 sec and re-implement timerEvent to get timer events to close your messagebox.

    # startTimer(2000) // before showing message box

    #void <ur class>::timerEvent(QTimerEvent *event)
    {
    this->lMessage->close();
    }
    I hope it would help you. - Vikas

  4. #4
    Registered User ashwinbhatks's Avatar
    Join Date
    May 2010
    Posts
    16
    Yes but still the OK button is displayed. I do not want the OK button to be shown on the screen. Is there any way to hide the OK button in QMessageBox

  5. #5
    Nokia Developer Moderator bogdan.galiceanu's Avatar
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471
    Yes, simply set the buttons to 0:
    Code:
    QMessageBox m;
    m.setStandardButtons(0);

  6. #6
    Registered User ashwinbhatks's Avatar
    Join Date
    May 2010
    Posts
    16
    Thank you. We managed to get the same functionality with the help of QLabel.

Similar Threads

  1. QMessageBox Icons to a Window
    By ras123 in forum Qt
    Replies: 8
    Last Post: 2010-08-11, 19:24

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved