I want to create my own widget toolkit, and I know it's possible without external tools(QT was written in C++, and so was wxWidgets). But I don't know how to do it, and I couldn't find anything in Google.

So how exactly do I create GUIs in C++ that way?

I'm on Linux.

For *nix you will want to study Motif, which is not free unless you use OpenMotif. If you don't want their tools either then use X11R6 (there might be newer versions though). I'm sure you will find tutorials with google. And if you are going to write an extensive toolkit of your own you will want to buy the entire collections of X11R6 books.