Call Baidu map on Qt in ubuntu environment

This part of the project I did is an interface. Click the map button on the interface to call Baidu map.
I went through a lot of setbacks when I made this call. At the beginning, I installed Qt Creator 5.9.9. When using the webengine control, the following prompt appeared.
Insert picture description here
At this time, I realized that my QT may lack this control. After searching, I found that QT would not download this control when it was downloaded by default. So I downloaded and installed it again. The downloaded version is still Qt Creator 5.9.9. Qt WebEngine was checked during the installation, and then the normal download process.
Insert picture description here
However, the error displayed in the first picture is still displayed after downloading, and the problem is not solved.

Then what I saw on the blog is the following response.
Insert picture description here
It seems that my software is 5.9, so webengine can be used

Insert picture description here
Obviously, the above information refers to the use in the win10 environment and refers to two compilers, but webengine only supports the MSVC compiler
Insert picture description here

and then? We are now running under the Ubuntu environment, so the compiler problem mentioned in this article is not related to my problem (but I have misunderstood it for a long time, so some blogs on the Internet can't be trusted, you should read more Observe more to see which one is suitable for your situation) QT uses the GCC compiler in the ubuntu environment, and webengine can be used on this compiler, so do not consider whether the compiler is compatible with it.

Insert picture description here

In the communication group, there was a big guy who said something like this, which made me want to switch to the old version of QT, and then I didn’t use webengine, but webkit, and I really downloaded the old version again. QT, but the interface after opening is completely different from that after 5.6. So I uninstalled it again. It is not recommended to download the too old version of QT here.
In fact, the big guy above has a mistake. The later version of QT still supports the WEB architecture.
At this time, a group of big guys said that they want to install a new version, which supports webengine. If I want to next QT, I still check the webengine component when downloading, but it is a new version.

The following is the dawn before success.
Create a new project
Three lines of code are added to the pro file:QT+=webenginewidgets QT+=webengine QT+=webchannel

If no error is reported, then the component is successfully added.
Add the following code to the .cpp file below
Insert picture description here

The third include is the container for placing the Baidu map.
You can use it now! ! !
Below is the final map display, you're done.
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_49648103/article/details/109583761