Used after a past-tense verb to indicate that one event happened and immediately another followed — 'no sooner had... than...'.
窓の外を見ると、雨が止んだかと思えばまた降り出した。
Looking out the window, the rain stopped and no sooner had it stopped than it started again.
彼は笑ったかと思えば、急に真剣な顔になった。
He smiled, and no sooner had he smiled than he suddenly looked serious.
電車が到着したかと思えばすぐに発車した。
The train arrived, and barely had it arrived when it departed.
Used to mean 'when (I) think that...'; expresses the idea that upon thinking of something a particular reaction or situation occurs.
いい天気だな、かと思えば急に雲が広がってきた。
I thought it was nice weather, but when I thought that, clouds suddenly gathered.
彼は真面目だな、かと思えば冗談を言って場を和ませる。
I think he's serious, but when I think that he makes a joke and lightens the mood.
新しいアイデアが浮かぶかと思えば、すぐに別の問題が気になってしまう。
Just when an idea comes to mind, another problem immediately draws my attention.