Skip to content

Instantly share code, notes, and snippets.

@0xlitf
Created March 8, 2016 08:35
Show Gist options
  • Select an option

  • Save 0xlitf/4d0cbec48e7ead697719 to your computer and use it in GitHub Desktop.

Select an option

Save 0xlitf/4d0cbec48e7ead697719 to your computer and use it in GitHub Desktop.
C++调用python时,object.h中变量为slots的问题
//解决办法,在object.h中头文件开始#undef slots 在最后#define slots
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#pragma comment(lib,"C:/Python34/libs/python34.lib")
#include <QtWidgets/QMainWindow>
#include "ui_mainwindow.h"
#include <QDebug>
#include "C:\Python34\include\Python.h"
class MyClass :public QObject
{
Q_OBJECT
public:
MyClass()
{
connect(this, SIGNAL(sig()), SLOT(test()));
}
~MyClass()
{
}
public slots:
void test()
{
qDebug() << "aa";
}
signals:
void sig();
private:
};
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindowClass ui;
};
#endif // MAINWINDOW_H
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment