Results 1 to 3 of 3

Thread: Input

  1. #1
    Join Date
    Dec 2011
    Posts
    15
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Input

    Hi

    Attached is my code, I want the window to close when I click on cancel on the hobbit selector window. I also want the enable the function that when I edit the combo box, the name I put will be added to the combo box options. Please assist.
    [CODE]
    [#include <QInputDialog>
    #include <QStringList>
    #include <QApplication>

    int main(int argc, char** argv) {
    QApplication app(argc, argv);
    app.setQuitOnLastWindowClosed(false);
    QStringList hobbits, yesno;
    hobbits << "Frodo" << "Bilbo" << "Samwise" << "Merry" << "Pippin";
    yesno << "yes" << "no";
    QString outcome, more, title("Hobbit Selector");
    QString query("Pick your favorite Hobbit");
    do {
    QString pick =
    QInputDialog::getItem(0, title, query, hobbits);
    outcome = QString("You picked %1, try again?").arg(pick);
    more = QInputDialog::
    getItem(0, "Pick a Hobbit", outcome, yesno, 1, false);
    } while (more == "yes");
    }]

  2. #2
    Join Date
    Dec 2011
    Posts
    15
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Input

    Hi Guys

    I figured out how to do the second part of the posting can someone please assist with first part.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Input

    With your code as it is you need to use the ok argument to QInputDialog::getItem() and use that as a termination condition on your loop.

    Really though... if your program is going to do anything meaningful with this input you will probably need to build a user interface of your own.

Similar Threads

  1. Input Dialog
    By Enoctaffie in forum Qt Programming
    Replies: 1
    Last Post: 15th February 2012, 13:25
  2. taking input from the input box
    By neutrino in forum Qt Programming
    Replies: 7
    Last Post: 30th September 2011, 17:09
  3. Raw Input in QT4
    By been_1990 in forum Qt Programming
    Replies: 5
    Last Post: 13th September 2010, 18:54
  4. input audio
    By addu in forum Qt Programming
    Replies: 9
    Last Post: 10th September 2009, 11:12
  5. regarding input widget
    By jagadish in forum Qt Tools
    Replies: 1
    Last Post: 28th June 2007, 12:07

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.