Results 1 to 3 of 3

Thread: mouseclick/keyclick not work for delegate widget inside view in QTest framework

  1. #1
    Join Date
    Feb 2012
    Posts
    10
    Thanks
    3

    Question mouseclick/keyclick not work for delegate widget inside view in QTest framework

    I am trying to use QTest::keyClick to simulate key press for delegate item in a view.

    But it seems I cannot simulate the operations below using qtest framework

    Qt Code:
    1. QTest::keyClick(treeview_->focusWidget(), Qt::Key_Down);
    2. QTest::keyClick(treeview_->focusWidget(), Qt::Key_Down);
    3. QTest::keyClick(treeview_->focusWidget(), Qt::Key_Enter);
    4.  
    5. //after these code. the value of the cell should be 4.
    To copy to clipboard, switch view to plain text mode 

    These codes above works well, if I put them into a normal qt application.

    But it doesn't work in qtest framework



    I also tried mouseclick, but got the same issue.

    My environment Qt5.5, ubuntu14.10

    Attachment is the code to reproduce the issue. I made some changes base on the example of Qt5.5 : QT_DIR/Examples/Qt-5.5/widgets/itemviews/spinboxdelegate

    1) after start spinboxdelegate, you can see that item(0,1) has changed to 4
    2) running the test in "qt_test_not_work", it will fail.

    spinboxdelegate.tar.gz


    Thanks.
    Last edited by govi1; 18th July 2015 at 04:08.

  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: mouseclick/keyclick not work for delegate widget inside view in QTest framework

    Your test needs to call QApplication:rocessEvents() in order for the editor closure to be processed and the value to make it into the model.

  3. The following user says thank you to ChrisW67 for this useful post:

    govi1 (18th July 2015)

  4. #3
    Join Date
    Feb 2012
    Posts
    10
    Thanks
    3

    Default Re: mouseclick/keyclick not work for delegate widget inside view in QTest framework

    It works now. Thanks!!

Similar Threads

  1. Catching all Signals from widget in QTest
    By cszawisza in forum Qt Programming
    Replies: 3
    Last Post: 10th December 2017, 23:14
  2. Qt 4.5 bugs in graphics view framework?
    By Cruz in forum Qt Programming
    Replies: 8
    Last Post: 25th April 2015, 20:09
  3. Mouseclick outside from widget
    By binio in forum Qt Programming
    Replies: 3
    Last Post: 25th March 2013, 05:53
  4. Replies: 9
    Last Post: 26th May 2011, 12:29
  5. QTest and QEventLoop inside a library
    By MementoMori in forum Qt Programming
    Replies: 1
    Last Post: 22nd February 2011, 15:38

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
  •  
Qt is a trademark of The Qt Company.