He said everything is meaningless, etc. This is not true in light of what God/Jesus teaches.
The last chapter of the book is where he comes back to his senses. No one disputes that much of the book is Solomon away from God and his sinful perspective, not divine revelation. Inspiration includes the lies of Satan and men. Job's comforters, so-called, and Job himself were rebuked by God for wrong thinking. Inspiration means these things are accurately recorded, including false statements. Revelation of truth would be from the mind of God, also accurately recorded.
I am not denying the inspiration of Scripture, but interpreting the book as intended, a contrast between the thinking of men away from God and then restored to God. Context is the key.
Even the Psalms have things from the mind of David that are not the mind of God. We consider the poetic nature and do not equate it with clear didactic or historical narrative portions. Proverbs are also general truisms, not wooden literal universal promises (generally, if you train up a child properly, this will bear fruit, but even perfect parent God had Israel go astray; godly parents can have bad kids due to free will, so the verse is not false, but the application of it; Acts 16 it is not always true that because you are saved, all your family will be...in that case/context it was true, but it is not a universal, unconditional promise as seen in Scripture and anecdote).