Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8065645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:44:01+00:00 2026-06-05T11:44:01+00:00

I’m trying to create a vector of custom items that I have created but

  • 0

I’m trying to create a vector of custom items that I have created but I encounter a very strange problem.

When I create an instance of my class I don’t have any problem but when I try to add it the vector I have a very long error and I don’t know what to make of it.

I don’t know if it helps but the m_mesureList is a private attribute of the class PanneauMesure.

Declaration in the .h:

std::vector<Mesure> m_mesureList;

Use:

void PanneauMesure::add(QPointF point1, QPointF point2, QPointF point3, QGraphicsItem *line1, QGraphicsItem *line2)
{
    Mesure mesure(point1, point2, point3, line1, line2, this);
    //m_mesureList.push_back(mesure);
}

error:

In file included from ..\testQt\/PanneauMesure.h:21,
                 from ..\testQt\PanneauMesure.cpp:1:
d:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtGui/qwidget.h: In copy constructor 'Mesure::Mesure(const Mesure&)':
..\testQt\/Mesure.h:14:   instantiated from 'void __gnu_cxx::new_allocator<_Tp>::construct(_Tp*, const _Tp&) [with _Tp = Mesure]'
d:\qtsdk\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/stl_vector.h:737:   instantiated from 'void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = Mesure, _Alloc = std::allocator<Mesure>]'
..\testQt\PanneauMesure.cpp:104:   instantiated from here
d:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtGui/qwidget.h:806: error: 'QWidget::QWidget(const QWidget&)' is private
..\testQt\/Mesure.h:14: error: within this context
In file included from d:\qtsdk\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/mingw32/bits/c++allocator.h:34,
                 from d:\qtsdk\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/allocator.h:48,
                 from d:\qtsdk\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/string:43,
                 from d:\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtCore/qstring.h:54,
                 from d:\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtCore/qobject.h:48,
                 from d:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtGui/qwidget.h:46,
                 from d:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtGui/QWidget:1,
                 from ..\testQt\/PanneauMesure.h:4,
                 from ..\testQt\PanneauMesure.cpp:1:
d:\qtsdk\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/ext/new_allocator.h: In member function 'void __gnu_cxx::new_allocator<_Tp>::construct(_Tp*, const _Tp&) [with _Tp = Mesure]':
d:\qtsdk\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/ext/new_allocator.h:105: note: synthesized method 'Mesure::Mesure(const Mesure&)' first required here 
In file included from ..\testQt\/PanneauMesure.h:21,
                 from ..\testQt\PanneauMesure.cpp:1:
d:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtGui/qwidget.h: In member function 'Mesure& Mesure::operator=(const Mesure&)':
..\testQt\/Mesure.h:14:   instantiated from 'void std::vector<_Tp, _Alloc>::_M_insert_aux(__gnu_cxx::__normal_iterator<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer, std::vector<_Tp, _Alloc> >, const _Tp&) [with _Tp = Mesure, _Alloc = std::allocator<Mesure>]'
d:\qtsdk\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/stl_vector.h:741:   instantiated from 'void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = Mesure, _Alloc = std::allocator<Mesure>]'
..\testQt\PanneauMesure.cpp:104:   instantiated from here
d:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtGui/qwidget.h:806: error: 'QWidget& QWidget::operator=(const QWidget&)' is private
..\testQt\/Mesure.h:14: error: within this context
In file included from d:\qtsdk\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/vector:69,
                 from d:\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtCore/qvector.h:52,
                 from d:\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtGui/qbrush.h:47,
                 from d:\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtGui/qpalette.h:47,
                 from d:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtGui/qwidget.h:49,
                 from d:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtGui/QWidget:1,
                 from ..\testQt\/PanneauMesure.h:4,
                 from ..\testQt\PanneauMesure.cpp:1:
d:\qtsdk\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/vector.tcc: In member function 'void std::vector<_Tp, _Alloc>::_M_insert_aux(__gnu_cxx::__normal_iterator<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer, std::vector<_Tp, _Alloc> >, const _Tp&) [with _Tp = Mesure, _Alloc = std::allocator<Mesure>]':
d:\qtsdk\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/vector.tcc:312: note: synthesized method 'Mesure& Mesure::operator=(const Mesure&)' first required here 

Edit, if it helps:

Mesure.cpp:

Mesure::Mesure(QPointF point1, QPointF point2, QPointF point3, QGraphicsItem *line1, QGraphicsItem *line2, QWidget *parent):
    QWidget(parent),
    m_hlayoutMesure(new QHBoxLayout(this)),
    m_buttonClose(new QToolButton(this)),
    m_labelAngle(new QLabel(this)),
    m_checkboxMesure(new QCheckBox(this)),
    m_point1(point1),
    m_point2(point2),
    m_point3(point3),
    m_line1(line1),
    m_line2(line2),
    m_angle(0)
{
    m_buttonClose->setText("X");
    m_labelAngle->setAlignment(Qt::AlignCenter);
    m_checkboxMesure->setChecked(true);
    m_hlayoutMesure->addWidget(m_checkboxMesure);
    m_hlayoutMesure->addWidget(m_labelAngle);
    m_hlayoutMesure->addWidget(m_buttonClose);
    m_hlayoutMesure->setSpacing(10);
    m_hlayoutMesure->setMargin(0);
    QObject::connect(m_buttonClose, SIGNAL(clicked()), this, SLOT(close()));
}

PanneauMesure.cpp:

PanneauMesure::PanneauMesure(QWidget *parent) :
    QWidget(parent),
    m_vlayoutTotal(new QVBoxLayout(this)),
    m_groupboxMesures(new QGroupBox("Mesures", this)),
    m_vlayoutGroupBoxMesures(new QVBoxLayout(m_groupboxMesures)),
    m_scrollareaMesures(new QScrollArea(m_groupboxMesures)),
    m_widgetMesures(new QWidget(m_groupboxMesures)),
    m_hlayoutMesures(new QHBoxLayout(m_widgetMesures)),
    m_vlayoutMesures(new QVBoxLayout(m_widgetMesures)),
    m_groupboxOptions(new QGroupBox("Options", this)),
    m_vlayoutOptions(new QVBoxLayout(m_groupboxOptions)),
    m_buttonRAZ(new QPushButton("Remise à zéro", m_groupboxOptions)),
    m_widgetAlpha(new QWidget(m_groupboxOptions)),
    m_hlayoutAlpha(new QHBoxLayout(m_widgetAlpha)),
    m_labelAlphaText(new QLabel("Alpha :", m_groupboxOptions)),
    m_labelAlphaValeur(new QLabel("50", m_groupboxOptions)),
    m_sliderAlpha(new QSlider(m_groupboxOptions)),
    m_hlayoutCouleur(new QHBoxLayout(m_groupboxOptions)),
    m_labelCouleur(new QLabel("Couleur :", m_groupboxOptions)),
    m_buttonCouleur(new QToolButton(m_groupboxOptions)),
    m_couleur(Qt::yellow),
    m_hlayoutLongueur(new QHBoxLayout(m_groupboxOptions)),
    m_labelLongueur(new QLabel("Longueur :  ", m_groupboxOptions)),
    m_spinboxLongueur(new QSpinBox(m_groupboxOptions)),
    m_longueur(20),
    m_hlayoutLargeur(new QHBoxLayout(m_groupboxOptions)),
    m_labelLargeur(new QLabel("Largeur :", m_groupboxOptions)),
    m_spinboxLargeur(new QSpinBox(m_groupboxOptions)),
    m_largeur(5),
    m_mesureList()
{
    // Alpha
    m_sliderAlpha->setMaximum(100);
    m_sliderAlpha->setValue(50);
    m_hlayoutAlpha->addWidget(m_labelAlphaText);
    m_hlayoutAlpha->addWidget(m_labelAlphaValeur);
    m_labelAlphaText->setAlignment(Qt::AlignRight);
    m_labelAlphaValeur->setAlignment(Qt::AlignLeft);
    m_sliderAlpha->setOrientation(Qt::Horizontal);
    QObject::connect(m_sliderAlpha, SIGNAL(valueChanged(int)), m_labelAlphaValeur, SLOT(setNum(int)));

    // Couleur
    QPixmap px(20, 20);
    px.fill(m_couleur);
    m_buttonCouleur->setIcon(px);
    m_hlayoutCouleur->addWidget(m_labelCouleur);
    m_hlayoutCouleur->addStretch(2);
    m_hlayoutCouleur->addWidget(m_buttonCouleur);
    m_hlayoutCouleur->addStretch(1);
    QObject::connect(m_buttonCouleur, SIGNAL(clicked()), this, SLOT(ouvrirCouleur()));

    // Longueur
    m_spinboxLongueur->setMinimum(1);
    m_spinboxLongueur->setValue(m_longueur);
    m_spinboxLongueur->setMaximum(999);
    m_hlayoutLongueur->addWidget(m_labelLongueur);
    m_hlayoutLongueur->addStretch(1);
    m_hlayoutLongueur->addWidget(m_spinboxLongueur);
    QObject::connect(m_spinboxLongueur, SIGNAL(valueChanged(int)), this, SLOT(sendParam()));

    // Largeur
    m_spinboxLargeur->setMinimum(1);
    m_spinboxLargeur->setMaximum(100);
    m_spinboxLargeur->setValue(m_largeur);
    m_hlayoutLargeur->addWidget(m_labelLargeur);
    m_hlayoutLargeur->addStretch(1);
    m_hlayoutLargeur->addWidget(m_spinboxLargeur);
    QObject::connect(m_spinboxLargeur, SIGNAL(valueChanged(int)), this, SLOT(sendParam()));

    // Options
    m_vlayoutOptions->addWidget(m_buttonRAZ);
    m_vlayoutOptions->addWidget(m_widgetAlpha);
    m_vlayoutOptions->addWidget(m_sliderAlpha);
    m_vlayoutOptions->addLayout((m_hlayoutCouleur));
    m_vlayoutOptions->addLayout((m_hlayoutLongueur));
    m_vlayoutOptions->addLayout((m_hlayoutLargeur));
    m_vlayoutOptions->setSpacing(0);
    QObject::connect(m_buttonRAZ, SIGNAL(clicked()), this, SLOT(remiseAZero()));

    // Mesures
    m_vlayoutMesures->addStretch(1);
    m_hlayoutMesures->addStretch(1);
    m_hlayoutMesures->addLayout(m_vlayoutMesures);
    m_hlayoutMesures->addStretch(1);
    m_widgetMesures->setLayout(m_hlayoutMesures);
    m_scrollareaMesures->setWidgetResizable(true);
    m_scrollareaMesures->setWidget(m_widgetMesures);
    m_scrollareaMesures->setFrameShape(QFrame::NoFrame);
    m_vlayoutGroupBoxMesures->addWidget(m_scrollareaMesures);
    m_vlayoutGroupBoxMesures->setMargin(0);

    // Total
    m_vlayoutTotal->addWidget(m_groupboxOptions);
    m_vlayoutTotal->addWidget(m_groupboxMesures);

}

void PanneauMesure::add(QPointF point1, QPointF point2, QPointF point3, QGraphicsItem *line1, QGraphicsItem *line2)
{
    Mesure mesure(point1, point2, point3, line1, line2, this);
    m_mesureList.push_back(mesure);
    //m_vlayoutMesures->insertWidget(0, &m_mesure);
    //QObject::connect(m_buttonRAZ, SIGNAL(clicked()), &m_mesure, SLOT(close()));
}

void PanneauMesure::remiseAZero()
{
    m_sliderAlpha->setValue(50);
    m_longueur = 20;
    m_spinboxLongueur->setValue(m_longueur);
    m_largeur = 5;
    m_spinboxLargeur->setValue(m_largeur);
    m_couleur = Qt::yellow;
    QPixmap px(20, 20);
    px.fill(m_couleur);
    m_buttonCouleur->setIcon(px);
    emit changementParam(m_couleur, m_longueur, m_largeur);
}

void PanneauMesure::ouvrirCouleur()
{
    QColor color = QColorDialog::getColor(m_couleur);
    if (color.isValid()) m_couleur=color;
    QPixmap px(20, 20);
    px.fill(m_couleur);
    m_buttonCouleur->setIcon(px);
    emit changementParam(m_couleur, m_longueur, m_largeur);
}

void PanneauMesure::sendParam()
{
    m_longueur = m_spinboxLongueur->value();
    m_largeur = m_spinboxLargeur->value();
    emit changementParam(m_couleur, m_longueur, m_largeur);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T11:44:04+00:00Added an answer on June 5, 2026 at 11:44 am

    As K-Ballo pointed out that you can’t have a sequence of not-copy-constructible elements I just stored a sequence of pointers like this:

    Declaration:

    std::vector<Mesure*> m_mesureList;
    

    Function:

    void PanneauMesure::add(QPointF point1, QPointF point2, QPointF point3, QGraphicsItem *line1, QGraphicsItem *line2)
    {
        Mesure* mesure = new Mesure(point1, point2, point3, line1, line2, this);
        m_mesureList.push_back(mesure);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.