Results 1 to 2 of 2

Thread: Qtest QTableWidget

  1. #1
    Join Date
    Nov 2009
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question Qtest QTableWidget

    I have used QTest regression tests for QlineEdits QComboBoxes etc. I now wish to use QTest methods on a QTableWidget.

    I cannot get the data from, say, the keyClicks method to appear in the "selected" cell of the QTableWidget.
    Can I "select" a cell by using QTest::mouseClick?
    QTableWidget items are not QWidgets - is that a fundamental problem?
    As QTableWidgetItem is not derived from QWidget, can I even use keyClicks?
    Any advice on testing QTableWidgets using QTest?

    Regards

    TC

  2. #2
    Join Date
    Mar 2010
    Location
    Volcano, Big Island, Hawaii
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qtest QTableWidget

    This is how I interact with a QTableWidget when using the QTest namespace:

    //Find the item in the table that you want to interact with
    QList<QTableWidgetItem *> item_list = table_widget->findItems("My Special Item", Qt::MatchExactly);

    //Identify the visual rectangle that contains this table item
    QRect item_rect = table_widget->visualItemRect(item_list[0]);

    //Move the mouse to the rectangle's center point, in the table's viewport
    QTest::mouseMove(table_widget->viewport(), item_rect.center());

    //Click on that table widget item
    QTest::mouseClick(table_widget->viewport(), Qt::LeftButton, Qt::NoModifier, item_rect.center());

    Hope this helps you!

Similar Threads

  1. Replies: 7
    Last Post: 18th September 2009, 10:59
  2. QComboBox in QTableWidget : display troubles.
    By Nyphel in forum Qt Programming
    Replies: 2
    Last Post: 13th October 2007, 23:29
  3. print QTableWidget
    By chak_med in forum Qt Programming
    Replies: 3
    Last Post: 4th November 2006, 18:46
  4. QTableWidget editing question
    By Trasmeister in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2006, 18:46
  5. Replies: 6
    Last Post: 5th March 2006, 21:05

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.