Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT5 moc cannot parse __declspec instruction
Qt 6.11 is out! See what's new in the release blog

QT5 moc cannot parse __declspec instruction

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kelloggs
    wrote on last edited by
    #1

    I am currently migrating a project from QT4 to QT5. I am now facing a problem that has not been there when using QT4 regarding dllexport and dllimport. Whenever declaring __declspec(..) for a method within the slots scope, the moc is returning a parse error. I have created a small, artificial example.

    qt5test.h
    @
    #ifndef QT5TEST2_H
    #define QT5TEST2_H

    #include <QtWidgets/QMainWindow>
    #include "ui_qt5test2.h"

    class qt5test2 : public QMainWindow
    {
    Q_OBJECT

    public:
    qt5test2(QWidget *parent = 0);
    ~qt5test2();

    public slots:
    __declspec(dllexport) void highlightSomething();

    private:
    Ui::qt5test2Class ui;
    };

    #endif // QT5TEST2_H
    @

    qt5test2.cpp
    @
    #include "qt5test2.h"

    qt5test2::qt5test2(QWidget *parent)
    : QMainWindow(parent)
    {
    ui.setupUi(this);
    }

    qt5test2::~qt5test2()
    {

    }

    void qt5test2::highlightSomething()
    {

    }
    @

    Output
    @
    1>------ Rebuild All started: Project: qt5test2, Configuration: Debug Win32 ------
    1> Moc'ing qt5test2.h...
    1> C:\Users\jcornelis\documents\qt5test\qt5test2\qt5test2\qt5test2.h(16): Parse error at ")"
    @

    Am i doing something wrong? I am a bit confused, since the project compiled flawlessly against Qt4.8.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved