Results 1 to 5 of 5

Thread: QValidator and ListWidget

  1. #1
    Join Date
    Mar 2008
    Posts
    68
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QValidator and ListWidget

    Hi ,
    I am using Qt4.3.4 and i am using QIntValidator for validating the Inputs of Line Edits.
    The Same Code when i was using with Qt4.2.2 was working. Can Anyone tell where the problem is ...?

    I Also Wanted to know if it is possible to Set Keyboard Shortcuts to each item in a ListWidget.


    --
    Thanks in advacne.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QValidator and ListWidget

    I Also Wanted to know if it is possible to Set Keyboard Shortcuts to each item in a ListWidget.
    Well, you can capture keyPressEvent for the list widget. And based ont he key pressed, set the corresponding item as selected, or whatever operation u want

    other way is to create actions and set shortcut for them. And on each action perform some operation,,,

    but I guess capturing keyPressEvent would be better

  3. #3
    Join Date
    Mar 2008
    Posts
    68
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QValidator and ListWidget

    My Another question was this.....

    I have used QIntValidator to validate lineedits,
    Qt Code:
    1. QIntValidator *min_vldtr;
    To copy to clipboard, switch view to plain text mode 
    the above code is a part of class declaration....

    Qt Code:
    1. min_vldtr=new QIntValidator(MIN_SEC,MAX_SEC,this);
    2. m_reg.lelatmin->setValidator(min_vldtr);
    To copy to clipboard, switch view to plain text mode 

    this is a class that inherits QObject and m_reg is the object for the class generated by the UIC....the above code is a part of the class constructor.

    this code works fine with Qt4.2.2 but the same code when i compiled with Qt4.2.2 the Validator performs in a weird manner. The Lineedit accepts only number as inputs but the range is not getting set properly.
    Can anyone suggest a solution for this problem

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

    Default Re: QValidator and ListWidget

    Could you post a minimal compilable example reproducing the problem?

  5. #5
    Join Date
    Mar 2008
    Posts
    68
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QValidator and ListWidget

    you can see the qt example....

    widgets/lineedits/
    from the Qt installation folder...

    there the validator is not working as per the code for QDoubleValidator.

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.