Qt错误:错误:没有匹配的函数来调用“ QHBoxLayout :: addItem(QPushButton *&)”

计划我修订

我正在尝试将项目添加到QHBox,但是我一直收到错误消息:

/media/root/5431214957EBF5D7/projects/c/qt/tools/plugandpaint/app/mainwindow.cpp:36: error: no matching function for call to ‘QHBoxLayout::addItem(QPushButton*&)’
     hlayout->addItem(m_button);
                              ^

我可能做错了什么?

主窗口

#ifndef MAINWINDOW_H
#define MAINWINDOW_H


#include <QHBoxLayout>

class PaintArea;

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow();

private slots:
    void handleButton();
    // Other slots

private:
    PaintArea *paintArea;
    QHBoxLayout *hlayout;

    // Other private items
};

#endif

主窗口

MainWindow::MainWindow() :
    paintArea(new PaintArea),
    scrollArea(new QScrollArea)
{

    // Create the button, make "this" the parent
    m_button = new QPushButton("My Button", this);
    // set size and location of the button
    m_button->setGeometry(QRect(QPoint(100, 100), QSize(200, 50)));

    // Connect button signal to appropriate slot
    connect(m_button, SIGNAL (released()), this, SLOT (handleButton()));

    hlayout = new QHBoxLayout;
    hlayout -> addItem(m_button);
    hlayout -> addItem(paintArea);

    scrollArea->setWidget(hlayout);
w1ck3dg0ph3r

您应该使用addWidget()代替。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

没有匹配的函数来调用sort()

Qt从QHBoxLayout中删除拉伸

没有匹配的函数来调用“ getline”

C ++ Boost Geometry错误:没有匹配的函数来调用“ assertion_failed”

为什么出现错误“没有匹配的函数来调用'A(A <... auto ...>)'”?

没有匹配的成员函数来调用“ push_back”错误

C ++错误:没有匹配的函数来调用'print_size'

C ++错误:没有匹配的函数来调用'simplex615 <arbitraryFunc> :: amoeba

QHBoxLayout的宽度不正确

错误:没有匹配的函数来调用“ make_pair”

没有匹配的函数来调用“连接”(QT)

QHBoxLayout如何有固定比例?

没有匹配的函数来调用

运算符>>错误:没有匹配的函数来调用

Qt-无法访问动态创建的QHBoxLayout小部件

C ++错误::没有匹配的函数来调用'function'

C ++:没有匹配的函数来调用

“不是...的成员”和“没有匹配的函数来调用”错误

没有匹配的函数来调用'std :: advance'错误

错误:没有匹配的函数可调用

C ++错误没有匹配的调用函数

Qt QListWidget addItem内存泄漏

发生没有匹配的函数来调用C ++中的错误

QFormLayout内的QHBoxLayout没有左对齐

没有匹配的函数调用'QGridLayout::addWidget(QPushButton, int&, int&)

为什么我的删除按钮没有删除 QHBoxLayout 上的所有小部件

“错误:没有匹配的函数调用...”

没有匹配的函数来调用“strlen”

为什么我收到 [错误] 没有匹配的函数来调用“car::car()”