tags:

views:

108

answers:

1

Hallo everyone,

I have gone through various threads on this topic but, nothing seems to solve my particular problem. Including testlib, makes the console window appear and there I didnot find any option to suppress this behaviour.

But my application still demands testlib to be present (because i badly wanted to use QTest::qWait() method), and no console window to appear. I tried a few options from the other threads but nothing is working. what should i do to suppress this console window even after using 'testlib"?

The options I tried are

  1. adding CONFIG -= console to my .pro file.

        QT += gui \    
            xml \
            core \
            testlib    
        CONFIG += qt \
            windows \
            uitools \
            release        
        CONFIG -= console        
        LIBS += extern/ftd2xx.lib        
        RC_FILE = res/AC-Core.rc        
        QMAKE_CXXFLAGS += -Wall \
    
  2. editing the qmake.conf file, the lines

    QMAKE_LFLAGS_CONSOLE = -Wl,-subsystem,console, to    
    QMAKE_LFLAGS_CONSOLE = -Wl,-subsystem,windows
    

Any other ideas to suppress the appearing of console window are welcome?

Thanks!

A: 

You don't have to use QTest to get the functionality of QTest::qWait(). If you look at the source code for qWait() you can see how it works and implement this function yourself:

inline static void qWait(int ms)
{
    Q_ASSERT(QCoreApplication::instance());

    QTime timer;
    timer.start();
    do {
        QCoreApplication::processEvents(QEventLoop::AllEvents, ms);
        QTest::qSleep(10);
    } while (timer.elapsed() < ms);
}
Arnold Spence
Or, even better, use local QEventLoop and QTimer::singleShot on event loop's quit() slot.
chalup