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. Cpp check marking Q_INVOKABLE member functions as unused
Forum Updated to NodeBB v4.3 + New Features

Cpp check marking Q_INVOKABLE member functions as unused

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 603 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_ramR Offline
    R_ramR Offline
    R_ram
    wrote on last edited by
    #1

    Hi all,

    When I'm trying to run cppcheck with my source code. After static code check cppcheck showing Q_INVOKABLE member functions as unused ones. But those functions have been used from qml's.

    Since my other c++ project are running with cppcheck tool, I want to strict with the same tool for Qt project too. Please let me know is it possible?

    J.HilkJ 1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      No direct way exist. You need to make some fooling around for compiler as if you are using this method. Something like typecasting method to void pointer or taking the address of method etc. I have not tried though.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      3
      • R_ramR R_ram

        Hi all,

        When I'm trying to run cppcheck with my source code. After static code check cppcheck showing Q_INVOKABLE member functions as unused ones. But those functions have been used from qml's.

        Since my other c++ project are running with cppcheck tool, I want to strict with the same tool for Qt project too. Please let me know is it possible?

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @R_ram
        to build up on what @dheerendra said,

        you can try if this would be enough to fool your compiler. It's a 1:1 redefinishion on Q_UNUSED

        #define Q_USED_BY_QML(x) (void)x;
        
        ....
        Q_USED_BY_QML(qmlFuntion())
        

        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        2
        • R_ramR Offline
          R_ramR Offline
          R_ram
          wrote on last edited by
          #4

          Thanks for your suggestions.

          Instead, cppcheck if I'm using qt clang tool will it helpful in the above scenario. If it clang is helpful how to use as command-line usage.

          thanks in advance.

          1 Reply Last reply
          0

          • Login

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