Forum


Notice to all users

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

Results 1 to 10 of 10
  1. #1
    Join Date
    January 2010
    Location
    Europe
    Posts
    12

    [Solved] QApplication & QWidget in the Plugin crashes

    I am trying to create a widget inside the plugin, however since you cant have 2 QApplications in one Project its not running stable.

    I am using QT 4.5.3 and visual studio 2008

    I've read that it should work with the qApp macro.
    But since the macro returns a NULL pointer it clearly does not work.

    So, was anyone actually able to display a widget?
    And if yes, how?

    It is kind of beyond why there isnt a function in the api where I can register/pass a QWidget pointer since the client is working with Qt and it shouldnt be a problem to let the client display plugin widgets.
    This way you could embed the plugins configwidget and have a uniform look for all config windows.
    And you could very easily add/extend existing parts of the client.


    Anyway, any suggestions as to how to get this working (stable ) are appreciated.
    Last edited by Honc__; February 10th, 2010 at 04:52 PM.

  2. #2
    Join Date
    July 2006
    Location
    Germany
    Posts
    11
    I did just create a simple Win32 dialog box (without anything in it) and the client crashed on me, so you are not alone with Qt.

  3. #3
    Join Date
    January 2010
    Location
    Germany
    Posts
    21
    I had the same problem when I tried to create a QT form.

    The following snippet shows what I did. First I thought the crash had sth. to do with the uninitialized argv pointer. But then I commented out everything above "ConfigDialog configDialog = (0, Qt:ialog);" and the crash were still there.

    Code:
    /* Plugin might offer a configuration window.I f ts3plugin_offersConfigure returns 0, this function does not need to be implemented. */
    void ts3plugin_configure(void* handle) {
    	// create a new instance of QApplication with params argc and argv
    	int argc = 0;
    	char **argv;
    	QApplication app( argc, argv );	
    	// create a new instance of MainWindow with no parent widget
    	ConfigDialog configDialog = (0, Qt::Dialog);
    	// Shows the widget and its child widgets.
    	configDialog.show();
    	ts3Functions.logMessage("QT application created", LogLevel_DEBUG, LOG_CHANNEL, NULL);
    	// Enters the main event loop and waits until exit() is called
    	// or the main widget is destroyed or by default the last window closed,
    	// and returns the value that was set via to exit()
    	// (which is 0 if exit() is called via quit()).
    	app.exec();
    }

  4. #4
    Join Date
    January 2010
    Location
    Switzerland
    Posts
    6
    currently (client beta9), you cannot use Qt (in a stable way) because Qt requires that _all_ of its functionality that could potentially cause drawing to be in the Qt main thread (also referred to as GUI thread). Since the ts3plugin_configure hook is not called by this said main thread, this requirement is hard to meet :-). It's done this way because other UI frameworks may require to be in a different thread when showing a window blocks. Still, Qt being the framework used by TS3 itself, it should be useable for plugin configuration windows. They promised me, the next beta will get a change, to make this work. Please see:

    http://forum.teamspeak.com/showthread.php?t=49772

    You also may read there, why the qApp macro returns a NULL pointer. Short version: creating an instance of QApplication in your plugin calls for trouble, because there's already one there, you just can't see it. You need to link against the same Qt libraries the TS3 application comes bundled with.
    Last edited by ch4llenger; January 17th, 2010 at 09:14 PM.

  5. #5
    Join Date
    January 2010
    Location
    Europe
    Posts
    12
    Thank you for clearing that up. Was pretty sure it was a thread problem, but since I've never tried to do it that way I was not certain.

    So the only solution would be a function where you can pass your widget to the client application so it can be displayed by the gui thread.

    I guess we'll have to wait for the next beta release then.
    Is there a release date for the next beta?
    Last edited by Honc__; January 17th, 2010 at 12:54 PM.

  6. #6
    Join Date
    January 2010
    Location
    Switzerland
    Posts
    6
    At least I'm not aware of a release date. I hope soon.

    As pointed out by PeterS in the other thread, the solution will not be a callback which can return a pointer to a QWindow. Instead, we will be given the choice wether the ts3plugin_configure hook is called from the main (gui) thread or by a separate thread, which should be enough to open a QWindow in a plugin and is a more generic solution, i.e. also helps with other UI frameworks that require drawing operations to be done in the main thread (for example Cocoa is one of them too).

  7. #7
    Join Date
    January 2010
    Location
    Europe
    Posts
    12
    With the latest beta (11) we now have the possibility to decide if the configure function is called from the gui thread which solves the widget in config function problem.

    However it doesnt solve the problem that you cant have your own widget in the init function. I am trying to create a topmost mousetransparent overlay widget that I would use to display who's talking (and maybe the chat).

    For that I would need to have the same option that the ts3plugin_configure function now got, but for the ts3plugin_init function.

    Would be nice to see something like that in the next beta

  8. #8
    Join Date
    January 2010
    Location
    Switzerland
    Posts
    6
    As far as I know, ts3plugin_init() is called from the main thread. My plugin loads the configuration window in this function and only uses ts3plugin_configure() to make it visible. And I just tested if I could make it visible in the init function too, which seems to work flawlessly. So maybe you run into a problem not related to threads, or it is UI framework specific. I'm using Cocoa on Mac.

  9. #9
    Join Date
    January 2010
    Location
    Europe
    Posts
    12
    Well I've got my overlay prototype working.
    But since its not working as intended (for now you have to start it through the config dialog -> open plugins -> select plugin -> press configure) its not very userfriendly.
    So is there anything planned so you could pass a QWidgetpointer to the client so he can display it?

  10. #10
    Join Date
    January 2010
    Location
    Europe
    Posts
    12
    You have to link again the release dlls of QT, and everything works fine.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Qwidget issues
    By USMCGhost in forum Skins / Icon & Sound Packs
    Replies: 5
    Last Post: February 8th, 2013, 10:42 PM
  2. TS3 crashes (Volume plugin)
    By Grimmy in forum Bug Reports [EN/DE]
    Replies: 7
    Last Post: May 21st, 2012, 10:46 AM
  3. Plugin [minGW32] crashes on message in Channel Chat
    By TSPlugin in forum Client Plugins / Lua Scripts
    Replies: 1
    Last Post: April 3rd, 2010, 08:19 AM
  4. Help Skinning QWidget and sub command
    By The-Angelus in forum Skins / Icon & Sound Packs
    Replies: 2
    Last Post: December 28th, 2009, 02:32 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
  •