Open a new dialog within a dialog



  • i have a client program running on one system with different lineedits which reads data from file and prints on the lineedits and on click of ok push button all the line edits value has to be displayed on the same gui running on server machine which is on other system

    my client and server programs are running fine when am displaying the received data at console .

    i was asked to write a pthread at the receiving end becoz i vll be receiving many messages concurrently
    it means that i have to run my gui and my server program separately

    now how should i do it

    and also can u tell me how can i open a dialog within a dialog

    thank u


  • Moderators

    Just run your communication in a QThread or a pool of QThreads (check out QConcurrent).

    As for the dialog question... you just do it, the same way you have opened the first dialog.



  • i was asked to do pthreads
    for that i have created pthread and in pthread_create
    i have to call my gui dialog i have created dialog as follows
    @
    #include<groundsystems.h> //my dialog.h name

    in thread_create(&t1,NULL,message,NULL);

    the above statement says that thread name is t1,message is my function

    (void *) message(void *)
    {

    GroundSystems gs;
    gs.show();
    }

    when i execute this it is throwing an error as undefined reference to groundsystems.h

    thought .h and .cpp are included

    how should i solve this issue
    can u please help me


  • Moderators

    Qt does not allow running GUI elements in a separate thread. You can move your logic to a thread, but all widgets have to remain in main GUI thread.

    If it's throwing "undefined reference" then it can't find the header. Check your project settings again. Maybe the path is wrong, or you forgot about INCLUDEPATH in your .pro file (if you are using qmake).



  • Hii...
    "Undefined reference " I think this is due to object that you have declared GroundSystems gs; inside the thread class ,You should pass the object reference of GroundSystems class (say gsObj)to pthread class and equalise it to this->gs=gsObj;
    so the reference can be assigned to gs object.

    I don't what is your idea regarding dialogs ,
    but if you are switching from 1--->2---->3 it is very simple by using show()/hide() functions.



  • few things:
    -as it was said, you either create and show in the server main thread one dialog per client after connection request is accepted and in the per client server worker thread you signal the dialog object(or other helper object) for updating the dialog(eventually the dialog must be destroyed if client worker thread exits), or trigger an external gui programm (dialog based) and do inter process communication between server and each gui instance (is harder)
    -imho no need of pthread as QThread has as backend pthread on unix platforms
    -QDialog within QDialog means that it has main dialog as parent: this is not as usual, since a dialog is intended to be used as a top-level window


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.