Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. German
  4. Fenster verstecken und wiederherstellen nach Thread
Forum Updated to NodeBB v4.3 + New Features

Fenster verstecken und wiederherstellen nach Thread

Scheduled Pinned Locked Moved Unsolved German
2 Posts 2 Posters 708 Views
  • 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.
  • K Offline
    K Offline
    knasan
    wrote on last edited by knasan
    #1

    Hallo Forum.

    Ich habe drei Klassen.
    Mein Hauptprogramm QWidget, eigene Klasse als Worker und eine Klasse die externe Kommandos ausführt via QProcess.
    Im QWidget habe ich den Worker initialisiert, dieser ruft mit QtConcurrent als signal ruft ein Prozess auf was wiederum eine Funktion aufruft für das auf aufrufen eines externen Programm.

    Mein Problem ist folgendes:
    Sobald in QWidget der Worker aufgerufen wird mache ich ein

    this->showMinimized();
    

    und es wird auch normal durchgeführt.
    Jetzt würde ich gerne auf das Programm warten und darauf Regieren.

    Problem ist jetzt im Worker oder für die externen Programme heraus kann ich ein showNormal() machen.
    Das Programm quittiert mit folgender Fehlermeldung (Programm stürzt nicht ab, es funktioniert einfach nur nicht)

    QObject::installEventFilter(): Cannot filter events for objects in a different thread.
    QObject: Cannot create children for a parent that is in a different thread.
    (Parent is Breeze::WidgetStateEngine(0x563da81c5b00), parent's thread is QThread(0x563da814f010), current thread is QThread(0x563da84b0660)
    QObject: Cannot create children for a parent that is in a different thread.
    (Parent is Breeze::WidgetStateEngine(0x563da81c5b00), parent's thread is QThread(0x563da814f010), current thread is QThread(0x563da84b0660)
    

    Kann mir jemand sagen wie es richtig geht?

    Hier meine Funktionen gekürzt:
    Worker:

    void Worker::startThread(QString threadcmd)
    {
        qDebug() << "Worker::startThread("<<threadcmd << ")";
        QFuture<void> t1 = QtConcurrent::run(process, threadcmd);
        qDebug() << "is Thread Finished: " << t1.isFinished();
    
    }
    

    Dieser ruft Intern eine Funktion als Thread auf (process)

    void process(QString threadcmd)
    {
        qDebug() << "Worker::process(" << threadcmd << ")";
    
        RunCommands run;
        bool ok = false;
        while(!ok) {
            ok = run.startCommand(threadcmd);
        }
        QuickConnect qc;
        qc.showNormal();
    
    }
    

    Hier meine startCommand

    bool RunCommands::startCommand(QString command)
    {
        qDebug() << "RunCommands::startCommand";
        qDebug() << "Command: " << command;
    
        QProcess *process;
        process = new QProcess;
        process->start(command);
    
        qDebug() << process->pid();
        qDebug() << process->processId();
        qDebug() << process->program();
        process->waitForFinished();
        qDebug() << "Procress endet";
        return true;
     }
    

    Kann mir jemand sagen wie ich das Umsetzten kann?
    Ich möchte lediglich das meine GUI weiterhin bedienbar aus und nach dem der Prozess beendet ist
    möchte ich eine Aktion ausführen (auf die GUI zugreifen usw.)

    1 Reply Last reply
    0
    • U Offline
      U Offline
      uafitadese
      wrote on last edited by
      #2
      This post is deleted!
      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