Skip to main content
edited body
Source Link
isan
  • 19
  • 4

you can add test_encoder.cpp in mainwindow.cpp and should create a pointer of class in mainwindow.h like this:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <rotary_encoder.h>
#include <QMainWindow>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
    rotary_encoderrotary_decoder *rc;
  void callback(int way);

};

and use main.cpp as default:

#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
}

mainwindow.cpp:

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
     rc=new rotary_encoderrotary_decoder();
     //your code
     //for call a function like:
     rc.re_cancel();
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::callback(int way)
{
    static int pos = 0;
       pos += way;
       qDebug() << "pos=" << pos ;
}

you can add test_encoder.cpp in mainwindow.cpp and should create a pointer of class in mainwindow.h like this:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <rotary_encoder.h>
#include <QMainWindow>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
    rotary_encoder *rc;
  void callback(int way);

};

and use main.cpp as default:

#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
}

mainwindow.cpp:

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
     rc=new rotary_encoder();
     //your code
     //for call a function like:
     rc.re_cancel();
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::callback(int way)
{
    static int pos = 0;
       pos += way;
       qDebug() << "pos=" << pos ;
}

you can add test_encoder.cpp in mainwindow.cpp and should create a pointer of class in mainwindow.h like this:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <rotary_encoder.h>
#include <QMainWindow>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
    rotary_decoder *rc;
  void callback(int way);

};

and use main.cpp as default:

#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
}

mainwindow.cpp:

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
     rc=new rotary_decoder();
     //your code
     //for call a function like:
     rc.re_cancel();
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::callback(int way)
{
    static int pos = 0;
       pos += way;
       qDebug() << "pos=" << pos ;
}
added 617 characters in body
Source Link
isan
  • 19
  • 4

you can add test_encoder.cpp in mainwindow.cpp and should create a pointer of class in mainwindow.h like this:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <rotary_encoder.h>
#include <QMainWindow>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
    rotary_encoder *rc;
  void callback(int way);

};

and use main.cpp as default:

#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
}

mainwindow.cpp:

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
     rc=new rotary_encoder();
     //your code
     //for call a function like:
     rc.re_cancel();
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::callback(int way)
{
    static int pos = 0;
       pos += way;
       qDebug() << "pos=" << pos ;
}

you can add test_encoder.cpp in mainwindow.cpp and should create a pointer of class in mainwindow.h like this:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <rotary_encoder.h>
#include <QMainWindow>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
    rotary_encoder *rc;
};

and use main.cpp as default:

#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
}

you can add test_encoder.cpp in mainwindow.cpp and should create a pointer of class in mainwindow.h like this:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <rotary_encoder.h>
#include <QMainWindow>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
    rotary_encoder *rc;
  void callback(int way);

};

and use main.cpp as default:

#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
}

mainwindow.cpp:

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
     rc=new rotary_encoder();
     //your code
     //for call a function like:
     rc.re_cancel();
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::callback(int way)
{
    static int pos = 0;
       pos += way;
       qDebug() << "pos=" << pos ;
}
Source Link
isan
  • 19
  • 4

you can add test_encoder.cpp in mainwindow.cpp and should create a pointer of class in mainwindow.h like this:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <rotary_encoder.h>
#include <QMainWindow>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
    rotary_encoder *rc;
};

and use main.cpp as default:

#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
}