×
Namespaces

Variants
Actions

TestEventList in Qt

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Creator IDE V 4.5 and Emulator
Compatibility
Platform(s): S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition, Qt 4.5
Symbian
Article
Keywords: QTestEventList
Created: mind_freak (09 Jun 2009)
Last edited: hamishwillee (11 Oct 2012)

Contents

Overview

Demonstrates how the QTestEventList class can be populated with GUI events that can be stored as test data for later usage, or be replayed on any QWidget.

Events will be executed in serial wise manner.

Preconditions

  • Download and Install the Qt SDK

Function

  • Adds a new key click to the list. The event will simulate the key qtKey with the modifiers and then wait for msecs milliseconds.
events->addKeyClick(Qt::Key_Space);
  • Simulates the events from the list one by one on the widget w. For an example, please read the QTestEventList class documentation.
events->simulate(line);

Source Code

Header File

#ifndef MYSIMU_H
#define MYSIMU_H
 
#include <QtGui/QWidget>
#include<QLineEdit>
#include<QTestEventList>
#include<QHBoxLayout>
#include<QLabel>
#include<QPushButton>
namespace Ui
{
class mysimuClass;
}
 
class mysimu : public QWidget
{
Q_OBJECT
 
public:
mysimu(QWidget *parent = 0);
~mysimu();
 
private:
QHBoxLayout *lay;
QLabel *lbl;
QTestEventList *events;
QLineEdit *line;
QPushButton *paste;
private slots:
void viral();
};
 
#endif // MYSIMU_H

Source File

#include "mysimu.h"
#include "ui_mysimu.h"
 
mysimu::mysimu(QWidget *parent)
: QWidget(parent)
{
lay=new QHBoxLayout(this);
lbl=new QLabel(this);
events=new QTestEventList(this);
paste=new QPushButton("PASTE",this);
events->addDelay(1000);
//This whole list is the list of GUI Events.
events->addKeyClick(Qt::Key_Space);
events->addKeyClick('a');
 
events->addKeyClick(Qt::Key_Space);
events->addKeyClick(Qt::Key_Backspace);
events->addKeyClick('b');
events->addKeyClick(Qt::Key_Space);
events->addKeyClick('c');
line=new QLineEdit();
 
lay->addWidget(line);
lay->addWidget(paste);
QObject::connect(paste,SIGNAL(clicked()),this,SLOT(viral()));
setLayout(lay);
showMaximized();
setStyleSheet("* { background-color:rgb(199,147,88); padding: 7px ; color:rgb(255,255,255)}");
}
 
mysimu::~mysimu()
{
 
}
void mysimu::viral()
{
events->simulate(line);
//This avtivate the list and the GUI events take place in the sequence in QTextEdit
}

Screenshot

Valid002.jpg

This page was last modified on 11 October 2012, at 04:18.
33 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×