in this program i'm writing the functions that have qt classes as parameters Qlabel, QSpinbox, etc. are causing compile errors, my other functions work fine

i get the same 2 errors for each QT object i use as an argument

this is the function definition that uses QT classes as 3 of the parameters the first isnt

void fraction::displayfraction(fraction toDis, QLabel nWhole, QLabel nNum, QLabel nDen)

this is a test function call that causes the error

MainWindow::MainWindow(QWidget *parent) :
    ui(new Ui::MainWindow)
    fraction myfraction(7,4,5);
    QLabel d;
    QLabel n; 
    QLabel w;
    /*error function*/myfraction.displayfraction(myfraction,w,n,d);

i get the same 2 errors for each QT object i use as an argument

C:\Users\James\programs\FrctnCltrV3-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Release\..\..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui\qlabel.h:165: error: 'QLabel::QLabel(const QLabel&)' is private

C:\Users\James\programs\FrctnCltrV3-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Release\..\FrctnCltrV3\mainwindow.cpp:14: error: initializing argument 2 of 'void fraction::displayfraction(fraction, QLabel, QLabel, QLabel)'

i'm 17 and kinda new to programming so the solution could be obvious, i might not find it

Recommended Answers

All 3 Replies

QLabel::QLabel(const QLabel&) is called the copy constructor, and it is indeed private, so you cannot use it. You are trying to use it by copying your object when you pass it to the function. You should accept a const reference to the object instead:

void Test(const QLabel& yourLabel)


Call by reference method is good here.
Try it.

sorry about replying so late, i didnt under your answers because i didnt understand the concept of pointers and purposely disabled copy constructors when posting my question

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.