Results 1 to 2 of 2

Thread: Best way of defining mandatory fields?

  1. #1
    Join Date
    Apr 2016
    Posts
    5
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Best way of defining mandatory fields?

    What is best way of defining mandatory fields inside QWidget/MainWindow view?
    I want to make few fields (ComboBoxes, LineEdit, and few SpinBoxes) mandatory by making them highlight when default values are selected on an event.

  2. #2
    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: Best way of defining mandatory fields?

    You should indicate which widgets are mandatory inputs in some way. Often this is with an asterisk in the label, e.g. "Name*:", or by setting the widget background or border to a different colour.

    By "on an event" I assume you mean when they push a button or select a menu item to trigger some process using the inputs. In that case, the slot that is triggered should check that all mandatory inputs have a suitable value. If they do then run the process, if not then call setFocus() on the input widget that has an unacceptable value, issue a message, and do not run the process.

    Another approach would be to monitor the changed signals of the manadatory fields. When any field changes check all the fields and if all are acceptable enable the button to trigger the process, disable it otherwise.
    Last edited by ChrisW67; 8th July 2016 at 21:58. Reason: updated contents

Similar Threads

  1. Replies: 1
    Last Post: 22nd November 2013, 17:18
  2. QWizard and mandatory field problems
    By Judd in forum Qt Programming
    Replies: 2
    Last Post: 5th August 2009, 11:50
  3. QWizard - mandatory fields
    By slava in forum Qt Programming
    Replies: 12
    Last Post: 12th February 2008, 13:52
  4. defining number
    By mickey in forum General Programming
    Replies: 1
    Last Post: 1st February 2008, 06:19
  5. Defining data format in c++
    By locus in forum General Programming
    Replies: 3
    Last Post: 13th April 2007, 19:40

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.