Re: [TFUI] testing Qt code
David Dibben <dibben-duq3b/zSlLYXvkv/[email protected]>
| Newsgroups | gmane.comp.programming.test-first-user-interfaces |
|---|---|
| Organization | The Japan Research Institute, Ltd. |
| Message-ID | <[email protected]> |
On Tue, 11 May 2004 22:06:04 -0700 (PDT) Phlip <phlipcpp-/[email protected]> wrote: > > Phlip wrote: > - Treat I/O Like a Spigot. When you want to see > a window in a specific state, such as just > after a test case, you should be able > to raise that window with very little > thinking or tweaking. Given reveal(aWin), > what can we put inside reveal that displays > _any_ window? For Qt, I might borrow the > source of the exec() method and replicate > it. Or I might marshall aWin into another > process space, and feed it to a QApplication > in there, if that works. At a first pass, I tried code below as an implementation for reveal. All Qt's windows derive from QWidget, so we can use that as the argument to reveal. Calling processEvents() means that no user interaction with the window is possible, only viewing. If user interaction is required then reveal needs to be slightly more complex. Regards David #include <qdialog.h> #include <qapplication.h> #include <iostream> void reveal(QWidget* widget) { // show the widget widget->show(); // ask Qt to process the paint events so we can see the widget qApp->processEvents(); } int main(int argc, char** argv) { QApplication qApp(argc, argv); //create an empty dialog object QDialog* dialog = new QDialog(); // reveal the dialog reveal(dialog); int dummy; std::cin >> dummy; // pause return EXIT_SUCCESS; } ------------------------ Yahoo! Groups Sponsor ---------------------~--> Yahoo! Domains - Claim yours for only $14.70 http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/nhFolB/TM ---------------------------------------------------------------------~-> To unsubscribe, email: TestFirstUserInterfaces-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/TestFirstUserInterfaces/ <*> To unsubscribe from this group, send an email to: TestFirstUserInterfaces-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/