Yes, you basically have the right idea; "which" as a question is used to select from a fixed set of choices. Thus, from a menu, "Which dessert will you choose?", but "What is your favourite dessert?" I think with a world-wide set of languages, it's a bit of a grey area: is it truly a fixed, limited set? Personally, I would probably use "what" in that case, but if you where talking about, say, class offerings at school or university, then "which" would be better.
Also, "which" can be used as a relative pronoun ("That's the dessert which I like"), and also as a determiner ("I had the lamb and the apricot mousse for lunch, which dessert is a favourite of my wife" [sorry, that's a bit contrived!]), and "what" isn't used for either purpose.