Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTest and mouseClick Function
QtWS25 Last Chance

QTest and mouseClick Function

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LongJohn
    wrote on last edited by
    #1

    Hi,

    can somebody explain me the simplest way to click a button or something else like a QComboBox in a QTest?
    I tried this:

    @
    QComboBox *type = new QComboBox();
    type->addItem( "1" );
    type->addItem( "2" );
    type->addItem( "3" );
    type->addItem( "4" );

    QVBoxLayout *vLayout = new QVBoxLayout();
    vLayout->addWidget( type);

    QWidget *myWidget = new QWidget();
    myWidget->setLayout( vLayout );

    myWidget->show();

    while ( !myWidget->isVisible() ) {
    QTest::qWait(400);
    }

    const int positionXTypeBox = 70;
    const int positionYTypeBox = 25;

    QTest::mouseMove ( myWidget, QPoint( positionXTypeBox, positionYTypeBox ), -1 );
    QTest::qWait( 1500 );
    QTest::mouseClick( myWidget, Qt::LeftButton, Qt::NoModifier, QPoint( positionXTypeBox, positionYTypeBox ), 100 );
    @

    the mouse was excatly over the QComboBox-Widget but nothing happens when the mouse was clicked..
    And what's the solution when the combobox is a private member of the widget?

    Thanks

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved