Results 1 to 5 of 5

Thread: Thread integration

  1. #1
    Join Date
    May 2011
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Exclamation Thread integration

    Hi,
    I developed a program using Visual C++ that contain a thread and i want to integrate him in a QT project to interact with a graphical interface.

    The problem is that i created the interface in a thread and i called it in the main function then i used the function that i have developed in VC++ that launch my other thread, the program do not creat this one and run only the interface.


    My main function:
    Qt Code:
    1. void main(int argc, char *argv[])
    2. {
    3. MyThread Window;
    4. C_DlmsManager Stack;
    5.  
    6. Window.run();
    7. Stack.Start();
    8.  
    9. }
    To copy to clipboard, switch view to plain text mode 


    The function that launch my thread:
    Qt Code:
    1. static DWORD WINAPI LaunchStack(LPVOID pvParam)
    2. {
    3. C_DlmsManager* pPile = (C_DlmsManager*)pvParam;
    4.  
    5. (*pPile).Initialize();
    6.  
    7. (*pPile).Manager();
    8.  
    9. return 1;
    10. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by nizarazou87; 10th May 2011 at 16:00.

  2. #2
    Join Date
    May 2011
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Thread integration

    no answer???
    i neeeeeeeeeeed help

  3. #3
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Thread integration

    First show us definition of MyThread class.

  4. #4
    Join Date
    May 2011
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Thread integration

    here is the definition of my thread:
    Qt Code:
    1. class MyThread : public QThread
    2. {
    3. public:
    4. void run();
    5. };
    6.  
    7. void MyThread::run()
    8. {
    9. int argc;
    10. char *argv[0];
    11.  
    12. QApplication a(argc, argv);
    13. MainWindow w;
    14.  
    15. w.show();
    16. a.exec();
    17. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Lykurg; 15th May 2011 at 14:28. Reason: changed [qtclass] to [code]

  5. #5
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Thread integration

    1. You should start a thread calling QThread::start method not Qthread::run
    2. For me Yours construction is strange. I don't think that it is correct to create QApplication object in thread another then main.

Similar Threads

  1. Replies: 5
    Last Post: 22nd February 2011, 21:21
  2. Replies: 7
    Last Post: 27th January 2011, 08:48
  3. Replies: 9
    Last Post: 28th November 2009, 20:31
  4. Replies: 16
    Last Post: 7th October 2009, 08:17
  5. Eclipse Integration sans Integration
    By ChrisW67 in forum Qt Tools
    Replies: 3
    Last Post: 17th March 2009, 07:29

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.