Results 1 to 3 of 3

Thread: Creating a timed menu in Main()

  1. #1
    Join Date
    May 2013
    Posts
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Creating a timed menu in Main()

    Using Qt5 and QCoreApplication I want to create a timed menu that waits 15 seconds for a response, and if one is not received, moves on to the eventloop and the rest of the program. This program is ran completely from the console. I have tried using a timed while loop, however

    Qt Code:
    1. cin.readLine();
    To copy to clipboard, switch view to plain text mode 

    stops the loop and waits for a response.

    Any ideas on how to go about creating this?

  2. #2
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Creating a timed menu in Main()

    Quote Originally Posted by simy307 View Post
    Using Qt5 and QCoreApplication I want to create a timed menu that waits 15 seconds for a response, and if one is not received, moves on to the eventloop and the rest of the program. This program is ran completely from the console. I have tried using a timed while loop, however

    Qt Code:
    1. cin.readLine();
    To copy to clipboard, switch view to plain text mode 

    stops the loop and waits for a response.

    Any ideas on how to go about creating this?

    !!! get a timer, with a flag set. if user inputs something readline returns with flag set to entered.
    else, if timer passed with no input, then write dummy chars to get rid of readline.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Creating a timed menu in Main()

    Quote Originally Posted by simy307 View Post
    Using Qt5 and QCoreApplication I want to create a timed menu that waits 15 seconds for a response, and if one is not received, moves on to the eventloop and the rest of the program. This program is ran completely from the console. I have tried using a timed while loop, however

    Qt Code:
    1. cin.readLine();
    To copy to clipboard, switch view to plain text mode 

    stops the loop and waits for a response.

    Any ideas on how to go about creating this?
    Setup a QSocketNotifier on stdin, connect to its signal and run the event loop (e.g. via QEventLoop). Together with a timer that will quit the loop after 15 seconds, you can set a mechanism appropriate for your task.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. main.cpp in creating new QWidget project
    By iamDAMON in forum Qt Programming
    Replies: 2
    Last Post: 1st October 2012, 20:20
  2. Main menu Qt Creator disappeared
    By inger in forum Newbie
    Replies: 2
    Last Post: 7th May 2012, 09:35
  3. Replies: 2
    Last Post: 19th May 2011, 08:37
  4. Creating a Main Window Application
    By gt.beta2 in forum Qt Tools
    Replies: 13
    Last Post: 24th February 2009, 19:45
  5. Replies: 1
    Last Post: 23rd July 2008, 10:19

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.