PDA

View Full Version : How to use standard COM method to link a Qt GCC C++ .exe and a project in MVS C++?



babygal
20th May 2010, 04:26
How to use standard COM method to link a Qt GCC C++ .exe and a project in MVS C++?
(Note: MVSC project code using class.)

Fragment of the MVSC header file code which is supposed to be included in Qt project(filename:catDataPreparator.h):-
---------------------------------------------------------------------------------------------------------------------------------------------------
class catDataPreparator
{
public:
// constructor
__declspec(dllexport) catDataPreparator();

// destructor
__declspec(dllexport) ~catDataPreparator(void);

// methods
//=========
// METHODS FOR GUI FORM
__declspec(dllexport) void processInputData(const char*, const char* , const int, const float, const float, const int, const float, const float );
-------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------
mainwindow.h which is Qt project header file,where catDataPreparator.h is included, code as below:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#pragma once

#include <QMainWindow>
#include <QPrinter>
#include <QDialog>
#include <QFrame>

#include "mysharedlib_global.h"
#include "catDataPreparator.h"

QT_BEGIN_NAMESPACE
class QCheckBox;
class QAction;
class QLabel;
class QMenu;
class QPlainTextEdit;
class QListWidget;
class QScrollArea;
class QScrollBar;
class QString;
class QText;

//external class//

class catDataPreparator;

QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
#ifdef widget
MainWindow(QWidget *parent = 0);
Dialog(QWidget *parent = 0);
#endif
MainWindow();

protected:
void closeEvent(QCloseEvent *event);

private slots:
void newFile();
void openImageFile(); //open();
void open();
void openTextFile();

bool save();
bool saveAs();
void about();
void aboutCPT();

void documentWasModified();
void import();
void importdialog();
void trimdialog();
void analysis1();

void print();
void zoomIn();
void zoomOut();
void normalSize();
void fitToWindow();

void setText();
void setOpenFileName();
void setFileName();
void setCMRFileName();
void setFrameNumber();
void setEdEs();

void newimport();


private:
void createActions();
void createMenus();
void createToolBars();
void createStatusBar();
void readSettings();
void writeSettings();
void createDockWindows();
bool maybeSave();
void loadFile(const QString &fileName);
bool saveFile(const QString &fileName);
void setCurrentFile(const QString &fileName);
void showData(const QString &data);
void showMessage(const QString &message);

void updateActions();
void scaleImage(double factor);
void adjustScrollBar(QScrollBar *scrollBar, double factor);

#ifndef QT_NO_PRINTER
QPrinter printer;
#endif
QDialog *importwindow;
QLabel *imageLabel;
QText *text;
QScrollArea *scrollArea;
QPushButton *myButton;

double scaleFactor;

QString strippedName(const QString &fullFileName);
QString curFile;
QPlainTextEdit *textEdit;

QListWidget *dirView;
QListWidget *dataList;
QListWidget *messageList;

QMenu *fileMenu;
QMenu *editMenu;
QMenu *viewMenu;
QMenu *dataMenu;
QMenu *analysisMenu;
QMenu *helpMenu;

QToolBar *fileToolBar;
QToolBar *editToolBar;

QAction *newAct;
QAction *openAct;
QAction *openTextFileAct;

QAction *saveAct;
QAction *saveAsAct;
QAction *exitAct;
QAction *cutAct;
QAction *copyAct;
QAction *pasteAct;
QAction *importAct;
QAction *importdialogAct;
QAction *trimdialogAct;
QAction *filenameAct;
QAction *framenumberAct;
QAction *EdEsAct;

QAction *aboutAct;
QAction *aboutCPTAct;
QAction *analysis1Act;
QAction *analysis2Act;
QAction *analysis3Act;
QAction *printAct;
QAction *fitToWindowAct;
QAction *zoomInAct;
QAction *zoomOutAct;
QAction *normalSizeAct;
QCheckBox *native;

public:

QLabel *questionLabel;
QLabel *textLabel;
QLabel *openFileNameLabel;
QLabel *setFileNameLabel;
QLabel *setFrameLabel;
QLabel *setEdEsLabel;

catDataPreparator dataPrep;
};
---------------------------------------------------------------------------------------------------------------------------------------eom
-S.O.S

squidge
20th May 2010, 09:11
Howto, example, etc are all available here: http://msdn.microsoft.com/en-us/library/ms809986.aspx

ChrisW67
20th May 2010, 10:40
babygal, please use [ code ] and [ /code] tags to enclose code. Makes it easier for everyone to read.

If it is a COM object then you need to read the ActiveQt documentation. Usually it comes down to:

Run dumpcpp against the COM dll or ocx
Include the generated header and implementation in your Qt project.
Create an instance of the proxy object that dumpcpp has defined/implemented.