Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QLoggingCategory in base class
Qt 6.12 LTS is out! See what's new in the release blog

QLoggingCategory in base class

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 273 Views 1 Watching
  • 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.
  • beeckscheB Offline
    beeckscheB Offline
    beecksche
    wrote on last edited by beecksche
    #1

    Hi,
    is it correct to use QLoggingCategory as shown below? It compiles and works, but I have no experience with this.

    class BaseClass{
        BaseClass(const char* categoryName = nullptr) : loggingCategory(categoryName ) {}
    
        void func() { qCDebug(loggingCategory) << "Debug output"; }
    
    private:
        QLoggingCategory loggingCategory;
    }
    
    class Class1 : public BaseClass{
        Class1() : BaseClass("my.category1") {}
    }
    
    class Class2 : public BaseClass{
        Class2 () : BaseClass("my.category2") {}
    }
    

    The reason behind this: I want to detect from which inherited class the debug message was created.

    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
    • Unsolved