Neue Dialoge dynamisch erstellen
Verfasst: 1. März 2009 18:13
Ich arbeite gerade an einem IRC-Projekt und habe folgendes Problem: Sobald ein Spieler eine Nachricht bekommt, soll sich ein Dialog zum Chatten öffnen. Ist dieser schon offen, wird die neue Nachricht in den Dialog geschrieben. Das kann daran erkannt werden, ob der Dialog sich in meiner Liste befindet.
Der Dialog heißt "pm" und wird so erstellt:
"pm" erbt von QMainWindow. Der Fehler: es öffnet sich einfach kein Dialog, und in der Konsole bekomme ich diese Fehler:
Danach spinnt das hauptsächliche Fenster komplett.
Wie kann ich das richtig hinbiegen?
Gesamter Source (steht unter der GPL3): http://intelcentino.in.funpic.de/upload/irc.zip (wird aber nicht kompilierbar sein, weil ich eigene Bibliotheken verwende)[/code]
Der Dialog heißt "pm" und wird so erstellt:
Code: Alles auswählen
void ircclient::event_privmsg (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count)
{
dump_event (session, event, origin, params, count); //Event dumper
QString text(params[1]); // kopiere die Nachricht
//suche nach einen zugehörigen Dialog (falls vorhanden)
for(list<pm*>::iterator itr = opened_pms.begin(); itr != opened_pms.end(); itr++)
{
if(!strcmp((*itr)->person.toAscii().data(), origin))
{
//vorhanden, also nur einfügen
(*itr)->tb_messages.insertPlainText(text);
return;
}
}
//nicht vorhanden - neuer Dialog wird erstellt
pm dlg(origin); // Initialisierung
dlg.show(); // Dialog anzeigen
opened_pms.push_back(&dlg); //Dialog in die Liste eintragen
dlg.tb_messages.insertPlainText(text); //Text in neuen Dialog einfügen
}
Code: Alles auswählen
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QObject::installEventFilter(): Cannot filter events for objects in a different thread.
QObject::installEventFilter(): Cannot filter events for objects in a different thread.
QObject::installEventFilter(): Cannot filter events for objects in a different thread.
Wie kann ich das richtig hinbiegen?
Gesamter Source (steht unter der GPL3): http://intelcentino.in.funpic.de/upload/irc.zip (wird aber nicht kompilierbar sein, weil ich eigene Bibliotheken verwende)[/code]