Home > Software engineering >  How to include libs into Qt project?
How to include libs into Qt project?

Time:08-24

I'm trying to figure out how to use the winapi enter image description here

.pro

QT        = core gui
greaterThan(QT_MAJOR_VERSION, 4): QT  = widgets
CONFIG  = c  17

LIBS  = -L"C:\Qt\Libs"
#win32:QMAKE_FLAGS  = -L"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\um\arm64"
#win32:LIBS  = cm-comctl32.lib

SOURCES  = \
    main.cpp \
    mainwindow.cpp

HEADERS  = \
    mainwindow.h

FORMS  = \
    mainwindow.ui

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS  = target

RESOURCES  = \
    rcdata.qrc

.h

#include <commctrl.h>
#pragma comment(lib, "Comctl32.lib") // <- warning: Unkown pragma ignored

.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    SetWindowSubclass((HWND)ui->tabWidget->find(0), ButtonProc, 0, (DWORD_PTR)&ui);
    DWORD err = GetLastError();
}

Using Qt Creator 8.0.1

Qt 6.3.1, compiler MinGW 64-bit

CodePudding user response:

It should be LIBS = -lcomctl32 for your compiler instead of the several other options you tried. This related question has additional detail: Adding external library into Qt Creator project

  • Related