Setting up Qt5 with Visual Studio 2015

后端 未结 4 729
闹比i
闹比i 2020-12-31 07:59

Searching Google for \'Qt5 - Windows 10 - VS 2015\' only brought up a blog post from April stating that support for VS 2015 is in the works (link).

The Qt5 downloads

4条回答
  •  滥情空心
    2020-12-31 08:20

    Building Qt

    1. Call the vcvarsall batch with the correct architecture, e.g.:

    call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64

    1. Call the Qt environment batch, e.g.,

    call C:\Qt\x64\vs2015\qt561-1_x64\5.6\msvc2015_64\bin\qtenv2.bat

    1. If using jom, add jom to path, e.g.,

    Set PATH=C:\Qt\x64\vs2015\qt561-1_x64\Tools\QtCreator\bin;%PATH%

    1. Set your Qt Makespec, e.g.,

    Set QMAKESPEC=win32-msvc2015

    1. Change directories to the source you want to build against, e.g.,

    cd C:\Qt\x64\vs2015\qt561-1_x64\5.6\Src\qtbase

    1. Run configure with whatever options you may need, e.g.,

    configure -platform win32-msvc2015 -nomake tests -nomake examples

    Add -opensource to your configure command if building open source Qt.

    1. Run nmake or jom -j %NUMBER_OF_PROCESSORS% or replace %NUMBER_OF_PROCESSORS% with the number of threads you want to utilize.

    Integrating Qt

    Take the contents of this code block and save it into a file called qt.natvis and place if here like this, C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Packages\Debugger\Visualizers\qt.natvis

    
    
    
        
        {{ x = {xp}, y = {yp} }}
        
            xp
            yp
        
    
    
    
        {{ x = {x1}, y = {y1}, width = {x2 - x1 + 1}, height = {y2 - y1 + 1} }}
        
            x1
            y1
            x2 - x1 + 1
            y2 - y1 + 1
        
    
    
    
        {{ x = {xp}, y = {yp}, width = {w}, height = {h} }}
        
            xp
            yp
            w
            h
        
    
    
    
        
        {{ width = {wd}, height = {ht} }}
        
            wd
            ht
        
    
    
    
        
        {{ start point = {pt1}, end point = {pt2} }}
        
            
                {pt1}
                
                    pt1
                
            
            
                {pt2}
                
                    pt2
                
            
    
        
    
    
    
        {{ size = {d->size} }}
        
            d->ref.atomic._q_value
            
                d->size
                (QPoint*)((reinterpret_cast<char*>(d)) + d->offset)
            
        
    
    
    
        {{ size = {d->size} }}
        
            
                d->size > 0
                    && ((((QPointF*)((reinterpret_cast<char*>(d)) + d->offset)[0]).xp
                == (((QPointF*)((reinterpret_cast<char*>(d)) + d->offset)[d->size - 1]).xp)
                    && ((((QPointF*)((reinterpret_cast<char*>(d)) + d->offset)[0]).yp
                == (((QPointF*)((reinterpret_cast<char*>(d)) + d->offset)[d->size - 1]).yp)
            
            d->ref.atomic._q_value
            
                d->size
                (QPointF*)((reinterpret_cast<char*>(d)) + d->offset)
            
        
    
    
    
        {{ x = {xp}, y = {yp} }}
        
            xp
            yp
        
    
    
    
        {{ x = {xp}, y = {yp}, z = {zp} }}
        
            xp
            yp
            zp
        
    
    
    
        {{ x = {xp}, y = {yp}, z = {zp}, w = {wp} }}
        
            xp
            yp
            zp
            wp
        
    
    
    
        
            {{ m11 = {_m11}, m12 = {_m12}, m21 = {_m21}, m22 = {_m22}, ... }}
        
        
            _m11
            _m12
            _m21
            _m22
            _dx
            _dy
        
    
    
    
        
            {{ m11 = {m[0][0]}, m12 = {m[1][0]}, m13 = {m[2][0]}, m14 = {m[3][0]}, ... }}
        
        
            m[0][0]
            m[1][0]
            m[2][0]
            m[3][0]
            m[0][1]
            m[1][1]
            m[2][1]
            m[3][1]
            m[0][2]
            m[1][2]
            m[2][2]
            m[3][2]
            m[0][3]
            m[1][3]
            m[2][3]
            m[3][3]
        
    
    
    
        
            {{ horizontal = {static_cast<Policy>(bits.horPolicy)}, vertical = {static_cast<Policy>(bits.verPolicy)}, type = {ControlType(1 << bits.ctype)} }}
        
        
            
                QSizePolicy::Policy::{static_cast<Policy>(bits.verPolicy)}
            
            
                QSizePolicy::Policy::{static_cast<Policy>(bits.horPolicy)}
            
            
                QSizePolicy::ControlType::{ControlType(1 << bits.ctype)}
            
            
                
                        Qt::Vertical (2)
                    
                
                        Qt::Horizontal (1)
                
            
            static_cast<int>(bits.verStretch)
            static_cast<int>(bits.horStretch)
            bits.hfw == 1
            bits.wfh == 1
        
    
    
    
        {ucs,c}
        ucs,c
        
            ucs > 0xff ? '\0' : char(ucs),c
            ucs,c
        
    
    
    
        {((reinterpret_cast<unsigned short*>(d)) + d->offset / 2),sub}
        ((reinterpret_cast<unsigned short*>(d)) + d->offset / 2),sub
        
            d->size
            d->ref.atomic._q_value
            
                d->size
                ((reinterpret_cast<unsigned short*>(d)) + d->offset / 2),c
            
        
    
    
    
        {((reinterpret_cast<char*>(d)) + d->offset),sb}
        ((reinterpret_cast<char*>(d)) + d->offset),sb
        
            d->size
            d->ref.atomic._q_value
            
                d->size
                ((reinterpret_cast<char*>(d)) + d->offset),c
            
        
    
    
    
        {{ size = {(d.d->size << 3) - *((reinterpret_cast<char*>(d.d)) + d.d->offset)} }}
        
            d.d->ref.atomic._q_value
            
                (d.d->size << 3) - *((reinterpret_cast<char*>(d.d)) + d.d->offset)
                
                    (*(reinterpret_cast<const unsigned char*>((reinterpret_cast<char*>(d.d)) + d.d->offset) + 1
                        + ($i >> 3)) & (1 << ($i & 7))) != 0
                
            
        
    
    
    
        
        {{ size = {s} }}
        
            a
            
                s
                ptr
            
        
    
    
    
        {{ julian day = {jd} }}
        
    
    
    
        {{ millisecond = {mds} }}
        {{ milliseconds = {mds} }}
        
            mds / 3600000, d
            mds / 3600000, d
            (mds % 3600000) / 60000, d
            (mds % 3600000) / 60000, d
            (mds / 1000) % 60, d
            (mds / 1000) % 60, d
            mds % 1000, d
            mds % 1000, d
        
    
    
    
        {d.pattern}
    
    
    
        
            ref._q_value
        
    
    
    
        strong reference to shared pointer of type {"$T1"}
        
            value == 0
            d->weakref._q_value
            d->strongref._q_value
        
    
    
    
        pointer to implicit shared object of type {"$T1"}
        
            d
        
    
    
    
        pointer to explicit shared object of type {"$T1"}
        
            d
        
    
    
    
        guarded pointer to subclass of QObject of type {"$T1"}
        
            wp.d == 0 || wp.d->strongref._q_value == 0 || wp.value == 0
        
    
    
    
        weak reference to shared pointer of type {"$T1"}
        
            d == 0 || d->strongref._q_value == 0 || value == 0
            d->weakref._q_value
            d->strongref._q_value
        
    
    
    
        scoped pointer to a dynamically allocated object of type {"$T1"}
        
            !d
        
    
    
    
        scoped pointer to dynamically allocated array of objects of type {"$T1"}
        
            !d
        
    
    
    
        ({first}, {second})
        
            first
            second
        
    
    
    
        
        {{ size = {d->size} }}
        
            d->ref.atomic._q_value
            
                d->size
                ($T1*)((reinterpret_cast<char*>(d)) + d->offset)
            
        
    
    
    
        
        
        {{ size = {d->end - d->begin} }}
        
            d->ref.atomic._q_value
            
                d->end - d->begin
                *reinterpret_cast<$T1*>((sizeof($T1) > sizeof(void*))
                    ? reinterpret_cast<Node*>(d->array + d->begin + $i)->v
                    : reinterpret_cast<$T1*>(d->array + d->begin + $i))
                
            
        
    
    
    
        {{ size = {d->size} }}
        
            d->ref.atomic._q_value
            
                d->size
                d->n
                n
                (*(QLinkedListNode<$T1>*)this).t
            
        
    
    
    
        ({key}, {value})
        
            key
            value
        
    
    
    
        
        {{ size = {d->size} }}
        
            d->ref.atomic._q_value
            
                d->size
                d->header.left
                left
                right
                *((QMapNode<$T1,$T2>*)this)
            
        
    
    
    
        (empty)
        ({key}, {value})
        
            key
            value
        
    
    
    
        
        {{ size = {d->size} }}
        
            d->ref.atomic._q_value
            
                d->numBuckets
                *((QHashNode<$T1,$T2>*)d->buckets[$i])
            
        
    
    
    
        (empty)
        ({key})
        
            key
        
    
    
    
        {{ size = {q_hash.d->size} }}
        
            q_hash
        
    
    
    
        ({*keyPtr}, {*t})
        
            *keyPtr
            *t
        
    
    
    
        {{ size = {hash.d->size} }}
        
            mx
            total
            hash.d->ref.atomic._q_value
            
                hash.d->size
                f
                n
                *((Node*)this)
            
        
    
    
    
        
    
        Invalid
        {d.data.b}
        {d.data.i}
        {d.data.u}
        {d.data.ll}
        {d.data.ull}
        {d.data.d}
        {d.data.c}
        
            {*((QMap<QString,QVariant>*)(d.is_shared ? d.data.shared->ptr
                : reinterpret_cast<const void *>(&d.data.ptr)))}
        
        
            {*((QList<QVariant>*)(d.is_shared ? d.data.shared->ptr
                : reinterpret_cast<const void *>(&d.data.ptr)))}
        
        
            {*((QString*)(d.is_shared ? d.data.shared->ptr
                : reinterpret_cast<const void *>(&d.data.ptr)))}
        
        
            {*((QStringList*)(d.is_shared ? d.data.shared->ptr
                : reinterpret_cast<const void *>(&d.data.ptr)))}
        
        
            {*((QByteArray*)(d.is_shared ? d.data.shared->ptr
                : reinterpret_cast<const void *>(&d.data.ptr)))}
        
        
            {*((QBitArray*)(d.is_shared ? d.data.shared->ptr
                : reinterpret_cast<const void *>(&d.data.ptr)))}
        
        
            {*((QDate*)(d.is_shared ? d.data.shared->ptr
                : reinterpret_cast<const void *>(&d.data.ptr)))}
        
        
            {*((QTime*)(d.is_shared ? d.data.shared->ptr
                : reinterpret_cast<const void *>(&d.data.ptr)))}
        
        DateTime
        Url
        Locale
        
            {*((QRect*)(d.is_shared ? d.data.shared->ptr
                : reinterpret_cast<const void *>(&d.data.ptr)))}
        
        
            {*((QRectF*)(d.is_shared ? d.data.shared->ptr
                : reinterpret_cast<const void *>(&d.data.ptr)))}
        
        
            {*((QSize*)(d.is_shared ? d.data.shared->ptr
                : reinterpret_cast<const void *>(&d.data.ptr)))}
        
        
            {*((QSizeF*)(d.is_shared ? d.data.shared->ptr
                : reinterpret_cast<const void *>(&d.data.ptr)))}
        
        
            {*((QLine*)(d.is_shared ? d.data.shared->ptr
                : reinterpret_cast<const void *>(&d.data.ptr)))}
        
        
            {*((QLineF*)(d.is_shared ? d.data.shared->ptr
                : reinterpret_cast<const void *>(&d.data.ptr)))}
        
        
            {*((QPoint*)(d.is_shared ? d.data.shared->ptr
                : reinterpret_cast<const void *>(&d.data.ptr)))}
        
        
            {*((QPointF*)(d.is_shared ? d.data.shared->ptr
                : reinterpret_cast<const void *>(&d.data.ptr)))}
        
        RegExp
        RegularExpression
        
            {*((QHash<QString,QVariant>*)(d.is_shared ? d.data.shared->ptr
                : reinterpret_cast<const void *>(&d.data.ptr)))}
        
        EasingCurve
        Uuid
        ModelIndex
        LastCoreType
        Font
        Pixmap
        Brush
        Color
        Palette
        Image
        Polygon
        Region
        Bitmap
        Cursor
        KeySequence
        Pen
        TextLength
        TextFormat
        Matrix
        Transform
        Matrix4x4
        Vector2D
        Vector3D
        Vector4D
        Quaternion
        PolygonF
        Icon
        LastGuiType
        SizePolicy
        UserType
        LastType
    
        
    
        
    
        d.data.c
    
        
            *((QString*)(d.is_shared ? d.data.shared->ptr
                : reinterpret_cast<const void *>(&d.data.ptr)))
        
    
        
            *((QByteArray*)(d.is_shared ? d.data.shared->ptr
                : reinterpret_cast<const void *>(&d.data.ptr)))
        
    
        
    
    
    
    

    You should now have the ability to debug with Qt in Visual Studio.

    Warning

    Even though Qt mentions it, they really don't emphasize how important is to properly clean if your build failed. This is what the site says, and I've added my own derived notes below the quoted text:

    Note: If you later need to reconfigure and rebuild Qt from the same location, ensure that all traces of the previous configuration are removed by entering the build directory and typing nmake distclean before running configure again.

    1. If your configuration using configure needs to change at all, you've got to run nmake distclean or jom -j %NUMBER_OF_PROCESSORS% distclean
    2. If your build failed, run clean, e.g., nmake clean or jom -j %NUMBER_OF_PROCESSORS% clean

    Then you should run configure with whatever options you need, and then nmake or jom -j %NUMBER_OF_PROCESSORS%.

提交回复
热议问题