Notice to all users

We are migrating towards a new forum system located at, as such this forum will become read-only on January 29, 2020

Results 1 to 5 of 5
  1. #1
    Join Date
    December 2009

    Question Adding a Button to the Teamspeak Toolbar

    Hi there,
    while developing a small plugin for a friend of mine, he asked me if I wasn't able to add a Button to the Toolbar in the Teamspeak-Client instead of having to use Plugin-Commands or assigning Hotkeys to Plugin-Commands.
    I remembered having read a Thread about getting access to the QWidgets, so I started with compiling a QT 4.7.2 (the Version the TS-Client uses) with msvc2010 and followed the instructions given in the mentioned post.
    The first thing I noticed was that Teamspeak seems to derive QToolbar in a class named "ImprovedToolBar" and uses that one. Because I have no headers defining the improvedtoolbar, I used AddAction on the Toolbar dynamic_casted to a QToolbar. While this does add a Button with the specified Image and Text, I have not been able to make QT call my functions when the user clicks the button.
    Since I'm not an Expert in QT and its Signal/Slot-System, I don't know if the problem lies with me (for using it somehow wrong) or with the functions not being virtual and every click being intercepted by the ImprovedToolBar.

    This is the (non-working) Button I managed to add: Name:  ts3_custombtn.png
Views: 1644
Size:  27.5 KB

    TL;DR: I try to add a custom button to the TS3-Toolbar, but I don't manage to react on clicks.

    I get the reference to the Toolbar by iterating on QApplication::allWidgets
    foreach(QWidget* pWidget, QApplication::allWidgets())
    	QToolBar* toolbar = dynamic_cast<QToolBar*>(pWidget); 
    	if(toolbar != 0)
    		_toolbar = toolbar; //Declared in header: QToolBar* _toolbar;
    This is how I add the Button:
    QString text = "Testtext";
    QIcon img = QIcon("Testimg.png");
    QAction* toolbarAction = _toolbar->addAction(qimg, qtext);
    Btn_Info_Container* container = new Btn_Info_Container(toolbarAction);
    I left out the code for caching the Container-Object and removing the action from the Toolbar before unloading the plugin for brevity.

    This is the Container class as defined in its header:
    class Btn_Info_Container : public QObject
    	Btn_Info_Container(QAction* action);
    	QAction* action;
    public slots:		
    	void trigger();
    And here are the Constructor and the Slot:
    Btn_Info_Container::Btn_Info_Container(QAction* action)
    	this->action = action;
    	connect((QObject*)action, SIGNAL(triggered()), this, SLOT(trigger()));
    void Btn_Info_Container::trigger()
    	std::cout << "Click!!";//This is never called
    I also tried to bind the Toolbar's "action_triggered" event, but that does not get called, too.
    How to react on user clicks on my button?

    Another method that could work would be to use the QToolBar.addWidget-Method instead of addAction (I haven't tried that one so far, will do that tomorrow), but what Widget-class do I need to preserve the look (including the current theme)? Is a QPushButton the way to go?

    EDIT: I've tried adding a QPushButton, but instead of solving the problem (it does not trigger my slot when clicked), it just looks very strange. Further, I discovered that typos in the SLOT- or SIGNAL-keywords don't produce compiler-errors, even though I thought that the type-safety was supposed to be the main benefit of the whole Signal/Slot-System over callbacks??

    EDIT2: I've even tried to subclass QAction and override it's virtual event () function to write something to the console, but still no luck. I think that the Problem is with the "improvedToolbar". I'll try to add my button to any other, QT-default-classes based widget to see if I'm right.

    Any help is appreciated.
    Last edited by addilind; January 4th, 2012 at 03:14 PM.

  2. #2
    Join Date
    June 2011
    Russian Federation
    I did not understand. It adds a button on the server? or just for yourself in the client?

  3. #3
    Join Date
    December 2009
    It adds a button to every client having my plugin enabled to avoid having to control the plugin through the chatbox; afaik there is no possibility to force plugins serverside exept for having a ServerQuery script that kicks everyone not having it enabled.
    But, since you don't seem familiar to the TS3-Plugin-Concept (at least from a programmer's point of view), I'd ask you not to post anything unrelated to a solution of the problem at hand in this thread, thanks.

  4. #4
    Join Date
    May 2010

    Just one thing about your Edit 1
    Quote Originally Posted by addilind
    EDIT: I've tried adding a QPushButton, but instead of solving the problem (it does not trigger my slot when clicked),
    Did you chnaged the signal (triggered) by clicked()

    QAction if for add action in a QMenu not add QPushButton.

  5. #5
    Join Date
    December 2009
    I think for a quick-fix I'll use the GUI-Options added by Plugin-API 15.
    I don't remember if I changed the Signal, but even if it worked, the PushButton on the Toolbar looked really ugly, so maybe I'd try adding a whole new Toolbar called Plugin-Toolbar, and use that one.
    About your info: I tried QAction first, as it is the usual way to add to a QMenu, but it did not work, so I tried using a QPushButton.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Adding custom button with url onto skin?
    By konradmm in forum Skins / Icon & Sound Packs
    Replies: 0
    Last Post: September 21st, 2015, 01:55 AM
  2. [Evaluation] Add a button "I'm" to toolbar.
    By rteam in forum Suggestions and Feedback
    Replies: 8
    Last Post: April 26th, 2014, 08:42 AM
  3. Replies: 3
    Last Post: December 8th, 2012, 02:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts