I have been tasked with modifying the GUI of a software, specifically I need to add a third node under "PORT-1" and "PORT-2" called "CONNECTIONS" . Now I haven't worked in Qt before and really would like some guidance.
Image: https://i.stack.imgur.com/QG0LE.jpg
From the start I was told that every node would have its own class and header, in which bespoke functionality could be added. I just need to show an empty "CONNECTIONS" node for the time being.
I went ahead and created the following header and class file:
Header: FCConnections.h
#ifndef FCCONNECTIONS_H
#define FCCONNECTIONS_H
#include <QObject>
#include "FCInterface.h"
class CFCConnections: public CResourceItem
{
Q_OBJECT
Q_PROPERTY(QString Name READ fnGetName
) public:
~CFCConnections();
public:
CFCInterface* pParent;
int fnGetName();
};
Q_DECLARE_METATYPE(CFCConnections*);
#endif
#ifndef FCCONNECTIONS_H
#define FCCONNECTIONS_H
#include <QObject>
#include "FCInterface.h"
class CFCConnections: public CResourceItem
{
Q_OBJECT
Q_PROPERTY(QString Name READ fnGetName)
public:
CFCConnections(QObject*);
~CFCConnections();
public:
CFCInterface* pParent;
int fnGetName();
};
Q_DECLARE_METATYPE(CFCConnections*);
#endif
To copy to clipboard, switch view to plain text mode
Class: FCConnections.cpp
#include "FCConnections.h"
#include "FCInterface.h"
#include "other headers"
CFCConnections
::CFCConnections(QObject* parent
) : CResourceItem
(parent
) {
pParent = (CFCInterface*) parent;
}
CFCConnections::~CFCConnections()
{
}
int CFCConnections:: fnGetName()
{
return 3;
}
#include "FCConnections.h"
#include "FCInterface.h"
#include "other headers"
CFCConnections::CFCConnections(QObject* parent) : CResourceItem(parent)
{
pParent = (CFCInterface*) parent;
}
CFCConnections::~CFCConnections()
{
}
int CFCConnections:: fnGetName()
{
return 3;
}
To copy to clipboard, switch view to plain text mode
The function ***fnGetName*** is just to demonstrate how I would get **READ** to work in **Q_PROPERTY**.
The main "**FCASM**" node is controlled by a class called "**FCInterface**". Now how would I go about making the "**CONNECTIONS**" node? Do I make a function in **FCInterface** or **FCConnections**? What function can I use?
The code block for the constructor of FCinterface is :
CFCInterface
::CFCInterface(QObject* parent
): CInterface
(parent
), CFCAbstract
() {
fnSetProperty
("objectName",
QString("%1").
arg("FCASM"));
fnSetInterfaceType( "FCASM" );
fnSetResourceBaseType(m_enDatabase);
fnSetResourceItemType(m_enInterface);
fnLoadDependentInfo();
}
CFCInterface::CFCInterface(QObject* parent): CInterface(parent), CFCAbstract()
{
fnSetProperty("objectName",QString("%1").arg("FCASM"));
fnSetInterfaceType( "FCASM" );
fnSetResourceBaseType(m_enDatabase);
fnSetResourceItemType(m_enInterface);
fnLoadDependentInfo();
}
To copy to clipboard, switch view to plain text mode
I realise this is a broad question but any suggestion would be welcome.
Bookmarks