Results 1 to 5 of 5

Thread: Simulating item selection in QTreeView.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2010
    Posts
    69
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Simulating item selection in QTreeView.

    I want to test my QTreeView items. At the moment when I click on the items my UI is transitioning from one state to another. I want to do the same thing by simulating the mouse click.

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

    Default Re: Simulating item selection in QTreeView.

    You can post a mouse press/mouse release event pair to the widget using QCoreApplication::postEvent()
    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.


  3. #3
    Join Date
    Mar 2010
    Posts
    69
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Simulating item selection in QTreeView.

    I got the solution. If someone wants to simulate a mouse click on QTreeView items, you can use QTest::mouseClick( QWidget * widget, Qt::MouseButton button, Qt::KeyboardModifiers modifier = 0, QPoint pos = QPoint(), int delay = -1 ) function.For me it works like a charm.

Similar Threads

  1. How to preserve selection in QTreeView
    By daren in forum Qt Programming
    Replies: 1
    Last Post: 17th December 2009, 03:14
  2. QTreeView selection strangeness
    By jkv in forum Qt Programming
    Replies: 1
    Last Post: 11th December 2009, 06:50
  3. Selection row in QtreeView
    By visor_ua in forum Qt Programming
    Replies: 2
    Last Post: 15th June 2008, 22:31
  4. QTreeView: selection behavior upon selected item removal
    By Pieter from Belgium in forum Qt Programming
    Replies: 6
    Last Post: 11th July 2007, 16:00
  5. Replies: 14
    Last Post: 9th November 2006, 08:35

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.