Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. problem on making an object

problem on making an object

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 323 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rezaMSLM
    wrote on last edited by rezaMSLM
    #1

    hello
    I want to make an object of

     QModbusClient
    

    in my Code. I have added these to my code:

    Header:	#include <QModbusClient>
    qmake:	QT += serialbus
    

    when I use this code in my *.h file:

    QModbusClient *ModbusObject;
    

    Receive No Error but if use this:

    QModbusClient *ModbusObject = new QModbusClient();
    

    Receive ERROR:

    ...\mainwindow.h:31: error: invalid new-expression of abstract class type 'QModbusClient'
         QModbusClient *ModbusObject = new QModbusClient();
    
                                                     ^
    

    why?

    jsulmJ 1 Reply Last reply
    0
    • R rezaMSLM

      hello
      I want to make an object of

       QModbusClient
      

      in my Code. I have added these to my code:

      Header:	#include <QModbusClient>
      qmake:	QT += serialbus
      

      when I use this code in my *.h file:

      QModbusClient *ModbusObject;
      

      Receive No Error but if use this:

      QModbusClient *ModbusObject = new QModbusClient();
      

      Receive ERROR:

      ...\mainwindow.h:31: error: invalid new-expression of abstract class type 'QModbusClient'
           QModbusClient *ModbusObject = new QModbusClient();
      
                                                       ^
      

      why?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @rezaMSLM As the error message says: QModbusClient is an abstract class.
      See https://doc.qt.io/qt-5/qmodbusclient.html#details
      You can create instances of QModbusRtuSerialMaster and QModbusTcpClient.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved