There is a project in github, that contain a script to easily accomplish this task. The project is called wifi-qr by kokoye2007. It can be cloned here.
To use the script, we need to clone the project from github.
$ git clone https://github.com/kokoye2007/wifi-qr
Once cloned, go into the project directory.
$ cd wifi-qr
To scan a QR code, and connect to the wifi information contained in the code
$ ./wifi-qr s
A camera interface will be displayed. Show our wifi QR code to the computer's webcam, and the script will read the QR code and automatically connect to the wifi using the information in the QR code.
Apart from scanning QR code and connecting to the wifi, this script has a lot more functions. You can read about all the functions here. Thank you to kokoye2007 for this excellent tool.