Results 1 to 2 of 2

Thread: How to open several windows (QWidgets) at once?

  1. #1
    Join Date
    Oct 2010
    Posts
    4
    Qt products
    Qt4

    Default How to open several windows (QWidgets) at once?

    Hello!

    I'm trying to create web interface testing program which should open two urls in two (or more) webkit windows simultaneously.

    I already did the code for the test automation which perfectly works in single way mode:

    1) User pushes 'Go' button and webkit (QWidget) window opens

    2) TestBot class object performs tests

    3) Closes

    Now my question: After clicking on the button 'Go', how do I open two (or three or more) webkit (QWidget) windows, I mean, how do I launch several TestBots simultaneously so they do all the work parallel?

    I understood, that I need to look at multithreads, I came up I need to inherit QThread into my TestBot class definition as 'class TestBot : public QThread', but is this right solution and do I do it right? What's to do next?

    Can't I just write code as:

    Qt Code:
    1. QThread process1;
    2. QThread process2;
    3. process1->start();
    4. //some code here
    5. process1->quit();
    6.  
    7. process2->start();
    8. //some code here
    9. process2->quit();
    To copy to clipboard, switch view to plain text mode 
    to make everything work parallel?

    I'm a newbie in Winapp world, I came from Web programming. Hope for your help!

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to open several windows (QWidgets) at once?

    'class TestBot : public QThread', but is this right solution and do I do it right? What's to do next?
    Well, putting your TestBot in to a thread sounds the right way to go, but we can't tell if you are doing it right since you didn't post any code.
    However, just subclassing is not enough.
    You have to adjust your code to work as worker thread.
    Based on the way you are asking, its sounds you don't really know what threaded programming really is.
    I recommend you first read some general principals of threaded programming, and then the QThread docs.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. open files in different windows
    By ramaha8319 in forum Qt Tools
    Replies: 1
    Last Post: 27th April 2009, 14:27
  2. Open Source on Windows
    By yogeshgokul in forum Installation and Deployment
    Replies: 3
    Last Post: 29th January 2008, 09:54
  3. open source for windows
    By Reese in forum Installation and Deployment
    Replies: 5
    Last Post: 26th November 2007, 15:15
  4. Installing Qt 4.1 (open source) on Windows XP
    By katrina in forum Installation and Deployment
    Replies: 8
    Last Post: 19th February 2006, 12:26

Tags for this Thread

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.