Results 1 to 10 of 10

Thread: How to create a "node" using QObject

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2017
    Posts
    10
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    Windows
    Thanks
    2

    Question How to create a "node" using QObject

    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
    Qt Code:
    1. #ifndef FCCONNECTIONS_H
    2. #define FCCONNECTIONS_H
    3. #include <QObject>
    4. #include "FCInterface.h"
    5.  
    6. class CFCConnections: public CResourceItem
    7. {
    8.  
    9. Q_OBJECT
    10. Q_PROPERTY(QString Name READ fnGetName)
    11. public:
    12. CFCConnections(QObject*);
    13. ~CFCConnections();
    14.  
    15.  
    16. public:
    17. CFCInterface* pParent;
    18. int fnGetName();
    19. };
    20. Q_DECLARE_METATYPE(CFCConnections*);
    21.  
    22. #endif
    To copy to clipboard, switch view to plain text mode 

    Class: FCConnections.cpp

    Qt Code:
    1. #include "FCConnections.h"
    2. #include "FCInterface.h"
    3. #include "other headers"
    4.  
    5.  
    6. CFCConnections::CFCConnections(QObject* parent) : CResourceItem(parent)
    7. {
    8. pParent = (CFCInterface*) parent;
    9.  
    10. }
    11. CFCConnections::~CFCConnections()
    12. {
    13.  
    14. }
    15.  
    16. int CFCConnections:: fnGetName()
    17. {
    18.  
    19. return 3;
    20. }
    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 :
    Qt Code:
    1. CFCInterface::CFCInterface(QObject* parent): CInterface(parent), CFCAbstract()
    2. {
    3. fnSetProperty("objectName",QString("%1").arg("FCASM"));
    4. fnSetInterfaceType( "FCASM" );
    5. fnSetResourceBaseType(m_enDatabase);
    6. fnSetResourceItemType(m_enInterface);
    7. fnLoadDependentInfo();
    8.  
    9. }
    To copy to clipboard, switch view to plain text mode 

    I realise this is a broad question but any suggestion would be welcome.
    Attached Images Attached Images

Similar Threads

  1. Replies: 2
    Last Post: 24th December 2015, 14:33
  2. Replies: 1
    Last Post: 20th November 2015, 11:02
  3. Replies: 3
    Last Post: 16th March 2015, 08:31
  4. Replies: 2
    Last Post: 27th January 2012, 18:29
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 20:05

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.