Back to Q: http://www.mindspring.com/~scarlson/synopt/
The basic Q theory is quite simple: (1) Matthew and Luke obviously had a version of Mark as one of their written sources, yet (2) Matthew and Luke also sometimes verbally agree on passages (especially sayings) which are absent from Mark. Then they must have had at least another common written source = Q (from German Quelle, "source").
Actually no document corresponding to Q has been found yet. It is certainly not the Gospel of Thomas as we know it, although the latter might depend on Q too. The theory is complicated if, as is probable, (1) Mark has known and used Q too and (2) there has been influence from successive editions of Matthew and Luke on the extant text of Mark. The last parameters make it more difficult to ascertain what exactly were the contents of Q. Moreover, it is quite likely that Q itself underwent successive revisions and additions.
The above link gives an interesting summary of the current theories.