CS 340 Wednesday 5/8/13 at 10:30am You are allowed 2 sides of notes on 8.5x11 inch paper Final Exam Topic List Qt Stuff - Signals and Slots and Event driven programming connect(widget, signal, classInstance, slot) - QPushButton clicked() signal - QLabel - QMessageBox (in its simplest form) - sender() How to customize an existing Qt Widget for a special purpose QTimer start() // often done in the constructor for the Application QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(update())); // often done is a slot for a button if (!timer->isActive()) { upDateCount = 0; timer->start(1000);// emit timeout() signal // after 1000 milliseconds } // the slot for the timeout signal void update() { QTimer* tm = (QTimer*) sender(); // assume upDateCount is reset to zero when // the time starts if (upDateCount < 10) { upDateCount ++; // perform desired action } else { tm->stop() } } QThread must be inherited so we can define the run() method Call the constructor to create the needed internal information for the OS to run/operate the thread start() - initializes & starts the thread in the OS and calls the run() method run() - contains the code that the thread will execute - we never should call run() explicitly QTcpSocket QTcpServer 1. Set up the connection - on server side create QTcpServer instance listen() connect() with newConnection signal - on client side create QTcpSocket instance connectToHost() - on Server Side use nextPendingConnection() to get QTcpSocket Instance 2. Send a message and receive the message only done with QTcpSockets instances - on Readers side connect() with readyRead signal - On Writers side write() of QTcpSocket instance - On readers side read() or set up QDataStream in the slot set up by the connect statement templated function and how to use it template X min (const X& v1, const X& v2) { if (v1 < v2) return v1; else return v2; } Complex c1, c2, c3; // assume op< is written for Complex Point p1, p2, p3; // assume op< is NOT written for Point c1 = min (c2, c3); p1 = min (p2, p3); ==> compiler error (or Link error) for min(p2, p3)