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. Sending a message to a Telegram bot
Forum Update on Tuesday, May 27th 2025

Sending a message to a Telegram bot

Scheduled Pinned Locked Moved Unsolved General and Desktop
41 Posts 4 Posters 6.2k 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.
  • J jenya7

    @JonB said in Sending a message to a Telegram bot:

    @jenya7 said in Sending a message to a Telegram bot:

    extern telebot m_telebot; works pretty well.

    Until that module links with something which does not define a global telebot m_telebot, and then it falls over. Every module you write relies on your main.cpp defining it, not good. Again, if you want to write code where modules use extern to reference something without getting it from the appropriate header file that is up to you.

    I'm loosing you.

    module.h

    extern MY_CLASS m_my_class;
    

    module.cpp

    MY_CLASS m_my_class;
    

    another_module.cpp

    #include "module.h"
    
    m_my_class.Method_1();
    

    How do you think a static class works? Not the same way?

    JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by JonB
    #41

    @jenya7
    This is "fine", insofar as you have changed the example to some other module.cpp/.h. But your code for telebot m_telebot; I thought was in main.cpp, and that would require including main.h elsewhere. I now think did not mean it was in main, that was not clear to me.

    While you choose to use a global variable, you already previously discovered (with your sys_params and TelegramBot ) that you have no opportunity to do anything initialisation-wise prior to its construction, which your code came a cropper on, you didn't understand and you had to work around. Same could happen with destructor. (You may or may not be aware, but additionally you can have a QString member (like your SYS_PARAMS sys_params) but you cannot have any QObject-derived members for such a class if you wanted them.) But it didn't put you off, so up to you.

    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