首页 > 其他分享 >vs2019 配置 qt 库

vs2019 配置 qt 库

时间:2022-11-29 19:12:56浏览次数:58  
标签:Qt vs2019 配置 编译器 vs static PATH qt

如标题所说,在 vs 编译器中调用 qt 库

首先安装一个适合 vs 的 qt 版本

不知道怎么安装的,可以参考:Visual Studio+Qt配置开发环境

qt 安装之后,我们只需要在 vs 编译器中设置 qt 的头文件目录和库目录,比如

 

 

 

 

 

 输入这些路径时,需要设置 QtDir 宏,我们可以直接在 vs 项目中的 .vcxproj.user 文件中手动输入配置就行,比如

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <ShowAllFiles>false</ShowAllFiles>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <QTDIR>D:\Qt\5.15.0\msvc2019_x86_static</QTDIR>
    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
    <QmlDebugSettings>file:$(ProjectGuid),block</QmlDebugSettings>
    <QmlDebug>-qmljsdebugger=$(QmlDebugSettings)</QmlDebug>
    <LocalDebuggerCommandArguments>$(QmlDebug)</LocalDebuggerCommandArguments>
    <LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3b$(PATH) $(LocalDebuggerEnvironment)</LocalDebuggerEnvironment>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugWin|Win32'">
    <QTDIR>D:\Qt\5.15.0\msvc2019_x86_static</QTDIR>
    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
    <QmlDebugSettings>file:$(ProjectGuid),block</QmlDebugSettings>
    <QmlDebug>-qmljsdebugger=$(QmlDebugSettings)</QmlDebug>
    <LocalDebuggerCommandArguments>$(QmlDebug)</LocalDebuggerCommandArguments>
    <LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3b$(PATH) $(LocalDebuggerEnvironment)</LocalDebuggerEnvironment>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">
    <QTDIR>D:\Qt\5.15.0\msvc2019_x86_static</QTDIR>
    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
    <QmlDebugSettings>file:$(ProjectGuid),block</QmlDebugSettings>
    <QmlDebug>-qmljsdebugger=$(QmlDebugSettings)</QmlDebug>
    <LocalDebuggerCommandArguments>$(QmlDebug)</LocalDebuggerCommandArguments>
    <LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3b$(PATH) $(LocalDebuggerEnvironment)</LocalDebuggerEnvironment>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <QTDIR>D:\Qt\5.15.0\msvc2019_x86_static</QTDIR>
    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
    <LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3b$(PATH) $(LocalDebuggerEnvironment)</LocalDebuggerEnvironment>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseDll|Win32'">
    <QTDIR>D:\Qt\5.15.0\msvc2019_x86_static</QTDIR>
    <LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3b$(PATH)</LocalDebuggerEnvironment>
  </PropertyGroup>
</Project>

 

如果你想在 vs 中打开 qt 项目并编译修改的话,可以在 VS 编译器中安装 QT VS Tools 拓展

 

如何安装的,请参考:Qt:03---Visual Studio安装Qt与使用


 

笔记:

今天查看 Qt VS Tools 时,发现该选项后面提示 qt visual studio tools version 2.9.1 initializing(rev.6),查看相关文章发现要更新 vs 编译器(我的是 vs2019),更新完后要重启电脑,

之后重新打开 vs 项目(里面包含 qt 界面库的调用),编译后报错,提示 error MSB4184: 无法计算表达式“[System.IO.File]... qt.natvis.xml not found,这个错误之前是没有的,研究后发现是编译器没有找到该文件,

解决方法是,复制一个已有的 qt5.natvis.xml 文件,并重名为 qt.natvis.xml,重新编译,没有错误

 

标签:Qt,vs2019,配置,编译器,vs,static,PATH,qt
From: https://www.cnblogs.com/strive-sun/p/16936403.html

相关文章

  • nginx配置域名访问/禁止ip访问
    一背景为什么要禁止ip访问?为了避免其他人把未备案的域名解析到自己的服务器IP,而导致服务器被断网,我们可以通过禁止使用ip访问的方法,防止此类事情的发生。二解决方法修改......
  • 非集群主机配置Hyper-v 实时迁移Hyper-V Live Migrations
    ​​https://learn.microsoft.com/zh-cn/windows-server/virtualization/hyper-v/deploy/set-up-hosts-for-live-migration-without-failover-clustering​​前提条件:1.属......
  • [django]sqlserver配置
    python3.8.8安装mssql-djangopipinstallmssql-djangopiplistPackageVersion-------------------asgiref3.5.2Django3.2.16mssql-django1......
  • QT程序新建一个线程
    1、创建好一个QT应用程序2、手动创建新线程类,继承QThread我这里新建的是下面newthread.h和newthread.cpp文件。newthread.h#ifndefNEWTHREAD_H#define......
  • git difftool配置
    gitconfig--globaldiff.toolvimdiffgitconfig--globaldifftool.promptfalsegitconfig--globalalias.ddifftoolgitconfig--globaldifftool.trustExitCode......
  • spring mvc 环境 过滤器设置utf8字符编码和配置Logback日志及json支持(四)
    web.xml配置过滤器支持中文的请求和响应<filter><filter-name>characterEncodingFilter</filter-name><filter-class>org.springframework.web.filter.Char......
  • iOS项目Flutter混合工程CI自动化配置
    CI整个流程简介:flutter项⽬源码仓库配置CI命令,配置runner与源码关联起来,flutter项⽬源码更新时,触发CI命令通过runner机器将flutter源码⽣成framework,然后通过git命令将⽣......
  • Maven配置ojdbc14-10.2.0.4.0.jar
    对于oralce的jdbc驱动,在maven上搜索到把pom配置复制到pom.xml里进行引用的时候出现下面这种情况<dependency><groupId>com.oracle</groupId><artifactId>ojdb......
  • VS2019使用Qt4.8.7
    取消系统变量中的Qt_INCLUDEPATH_。C:\Users\octob\AppData\Local\QtMsBuild中添加qt4.natvis.xml,qt4.natvisforvisualstudio2015forqt4IverifiedQString,Q......
  • 解决Qt msvc编译器中文乱码
    编码知识科普参考彻底解决Qt中文乱码以及汉字编码的问题(UTF-8/GBK)_利白的博客-CSDN博客_qt中文乱码解决方法上文讲到了QString显示中文乱码的原因。我的理解qt先对输入......