1

So i barely have any experience at all with C++, and im trying to port a Dynamic Library so it doesn't use DirectX/Windows stuff, i've decided to pick Qt, as the editor is easy on me and its compatible with Windows, Linux and Mac.

Considering almost 99% of the crucial code is written in C externs(which is a language im comfortable in) i started toying with c++ and started to understand some syntax like constructors, deconstructors etc...

But now i wanna do something like

extern "C"
int DisableComboBox(){
    //something that exposes the cpp class variables, objects, etc...
    ui->DeviceComboBox->setEnabled(false);
}

I've been coding for like 6 hours, so at this point im willing to hammer in the solution, i've tried doing a function like

void TSDRPlugin_ExtIO::DisableCombo(){
    ui->DeviceComboBox->setEnabled(false);
}

and then calling DisableCombo(); inside the C space, making my header something like

#ifndef TSDRPLUGIN_EXTIO_H
#define TSDRPLUGIN_EXTIO_H
#ifdef WIN43
    #define LIBRTL_API __declspec(dllexport)
#else
    #define LIBRTL_API
#endif
 #ifdef __cplusplus
 #define EXTERNC extern "C"
 #else
 #define EXTERNC
 #endif
EXTERNC void DisableComboBox();

 #undef EXTERNC



#include <QMainWindow>


QT_BEGIN_NAMESPACE
namespace Ui { class TSDRPlugin_ExtIO; }
QT_END_NAMESPACE

class TSDRPlugin_ExtIO : public QMainWindow
{
    Q_OBJECT

public:
    void DisableCombo();
    TSDRPlugin_ExtIO(QWidget *parent = nullptr);
    ~TSDRPlugin_ExtIO();

private:
    Ui::TSDRPlugin_ExtIO *ui;
};
#endif // TSDRPLUGIN_EXTIO_H

unfortunately it caused a new issue saying that DisableCombo() was undefined(the error that is similar in output to when you include a library but you don't link it with a flag on gcc)

So is there something i've missed? i've been trying a lot of different things and thinking of new solutions but i can't think of any, and me being a complete newbie to Cpp is not helping

Imeguras
  • 436
  • 6
  • 18

0 Answers0