当我使用Qt5的新信号插槽连接功能时,CLion显示错误

时间:2016-02-24 15:47:33

标签: qt5 clion

我正在开发Qt5应用程序,但是当我使用新的信号槽连接功能时,CLion会向我显示错误,“不兼容的指针类型'const char '和'void()(bool )“”。我确定lib是Qt5。我该怎么做才能解决问题。 这是我的代码(OS X 10.11.3)。

// KSMainWindow.cpp
#include "KSMainWindow.h"
#include <QMenuBar>
#include <QToolBar>
#include <QDebug>

KSMainWindow::KSMainWindow(QWidget *parent) : QMainWindow(parent) {
    setWindowTitle(tr("KSText"));

    openAction = new QAction(tr("&Open..."), this);
    saveAction = new QAction(tr("&Save..."), this);

    QMenu *file = menuBar()->addMenu(tr("&File"));
    file->addAction(openAction);
    file->addAction(saveAction);

    textEdit = new QTextEdit(this);
    setCentralWidget(textEdit);

    connect(openAction, &QAction::triggered, this, &KSMainWindow::openFile);
    connect(saveAction, &QAction::triggered, this, &KSMainWindow::saveFile);
}

KSMainWindow::~KSMainWindow() {
    delete openAction;
    delete saveAction;
    delete textEdit;
}

void KSMainWindow::openFile() {
    qDebug() << "Open";
}

void KSMainWindow::saveFile() {
    qDebug() << "Save";
}

CLion希望&amp; QAction :: triggered转换为const char *。

这是我的CMakeLists.txt

cmake_minimum_required(VERSION 3.3)
project(demo8)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(EXECUTABLE_OUTPUT_PATH ./bin)
find_package(Qt5 REQUIRED COMPONENTS Widgets Core Gui)
aux_source_directory(./src SRC_LIST)

add_executable(${PROJECT_NAME} MACOSX_BUNDLE ${SRC_LIST})
qt5_use_modules(${PROJECT_NAME} Widgets Core Gui)

0 个答案:

没有答案