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 7926587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:50:31+00:00 2026-06-03T18:50:31+00:00

I have this .h file #ifndef VISUALSETTINGS_H #define VISUALSETTINGS_H #include <QPair> #include <QDataStream> class

  • 0

I have this .h file

#ifndef VISUALSETTINGS_H
#define VISUALSETTINGS_H

#include <QPair>
#include <QDataStream>

class VisualSettings
{
    public:
        VisualSettings();
        VisualSettings(QPair<int, int>, QPair<int, int>);
        QPair<int, int> getUpper();
        void setUpper(QPair<int, int>);
        QPair<int, int> getLower();
        QPair<int, int> setLower(QPair<int, int>);

    private:
        QPair<int, int> upper;
        QPair<int, int> lower;
};

QDataStream &operator<<(QDataStream &out, const VisualSettings &vs);
QDataStream &operator>>(QDataStream &in, VisualSettings &vs);

#endif // VISUALSETTINGS_H

And i have this .cpp(a part of it)

#include "visualsettings.h"

VisualSettings::VisualSettings()
{
    upper.first = 0;
    upper.second = 0;
    lower.first = 0;
    lower.second = 0;
}

VisualSettings::VisualSettings(QPair<int, int> u, QPair<int, int> l)
{
    upper.first = u.first;
    upper.second = u.second;
    lower.first = l.first;
    lower.second = l.second;
}

QPair<int, int> VisualSettings::getUpper()
{
   return upper;
}

I am testing this class like this:

QPair<int, int> q1(2,3);
QPair<int, int> q2(4, 5);

VisualSettings v(q1, q2);

//QPair<int, int> q3 = v.getUpper();

//cout << v.getUpper().first;// << " - " << vs.getUpper().second << endl;

I get this error for this constructor:

main.obj:-1: error: LNK2019: unresolved external symbol “public: __thiscall VisualSettings::VisualSettings(struct QPair,struct QPair)” (??0VisualSettings@@QAE@U?$QPair@HH@@0@Z) referenced in function _main

If i use VisualSettings vs() when i do vs.getUpper() i get the error:

C:\Users\Alex\testing-build-desktop-Qt_4_8_0_for_Desktop_-MSVC2010_Qt_SDK__Debug..\testing\main.cpp:23: error: C2228: left of ‘.getUpper’ must have class/struct/union

I noticed that even if a declare a QList and use list.at(0) i get the same error(must have…).

What could be the problem?

LATER EDIT
The answer from @johnathon helped me, but I have another problem. I overwrite the operators << and >> like this:

QDataStream &operator<<(QDataStream &out, const VisualSettings &vs)
{
    out << vs.getUpper().first << vs.getUpper().second;
    out << vs.getLower().first << vs.getLower().second;

    return out;
}

QDataStream &operator>>(QDataStream &in, const VisualSettings &vs)
{
    QPair uaux(0, 0);
    in >> uaux.first >> uaux.second;
    vs.setUpper(uaux);

    QPair laux(0, 0);
    in >> laux.first >> laux.second;
    vs.setLower(laux);

    return in;
}

I get this error:

C:\Users\Alex\testing-build-desktop-Qt_4_8_0_for_Desktop_-MSVC2010_Qt_SDK__Debug..\testing\visualsettings.cpp:42: error: C2662: ‘VisualSettings::getUpper’ : cannot convert ‘this’ pointer from ‘const VisualSettings’ to ‘VisualSettings &’
Conversion loses qualifiers

C:\Users\Alex\testing-build-desktop-Qt_4_8_0_for_Desktop_-MSVC2010_Qt_SDK__Debug..\testing\visualsettings.cpp:42: error: C2228: left of ‘.first’ must have class/struct/union

What could be the problem?

Also I have another question. If at another class i use an VisualSettings object, in .h i declare it like VisualSettings vs, in the constructor of that class, can i say vs = new VisualSettings(1,2) or vs(1,2); so the question is how i call the constructor of VisualSetting in the constructor of another class(if the VisualSettigs object is variable of the class)?

LATER LATER EDIT:

I still got errors at my program and I don’t know how to solve it. So I wanted to overwite operator >>

class VisualSettings
{
............
};

QDataStream &operator<<(QDataStream &out, const VisualSettings &vs);
QDataStream &operator>>(QDataStream &in, VisualSettings &vs);

In the .cpp

QDataStream &operator<<(QDataStream &out, const VisualSettings &vs)
{
    out << vs.getUpper().first << vs.getUpper().second;
    out << vs.getLower().first << vs.getLower().second;

    return out;
}

I get this error:

C:\Users\Alex\testing-build-desktop-Qt_4_8_0_for_Desktop_-MSVC2010_Qt_SDK__Release..\testing\visualsettings.cpp:44: error: C2662: ‘VisualSettings::getLower’ : cannot convert ‘this’ pointer from ‘const VisualSettings’ to ‘VisualSettings &’
Conversion loses qualifiers
C:\Users\Alex\testing-build-desktop-Qt_4_8_0_for_Desktop_-MSVC2010_Qt_SDK__Release..\testing\visualsettings.cpp:44: error: C2228: left of ‘.first’ must have class/struct/union

I have another class

class Playlist
{
................
};

bool caseArtistLessThan(const SongInfo &s1, const SongInfo &s2);

In .cpp i have:

bool caseArtistLessThan(const SongInfo &s1, const SongInfo &s2)
{
    QString str1(ID3_GetArtist(&s1.getTag()));
    QString str2(ID3_GetArtist(&s2.getTag()));

    return str1 < str2;
}

I get the error:

C:\Users\Alex\testing-build-desktop-Qt_4_8_0_for_Desktop_-MSVC2010_Qt_SDK__Release..\testing\playlist.cpp:20: error: C2662: ‘SongInfo::getTag’ : cannot convert ‘this’ pointer from ‘const SongInfo’ to ‘SongInfo &’
Conversion loses qualifiers
C:\Users\Alex\testing-build-desktop-Qt_4_8_0_for_Desktop_-MSVC2010_Qt_SDK__Release..\testing\playlist.cpp:20: error: C2662: ‘SongInfo::getTag’ : cannot convert ‘this’ pointer from ‘const SongInfo’ to ‘SongInfo &’
Conversion loses qualifiers

Can somebody help me solve this problems? I don’t understand why it doesn’t works. I’ve seen a lot of examples and I’ve done just like in that examples. What could be the problem?

  • 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-03T18:50:33+00:00Added an answer on June 3, 2026 at 6:50 pm

    About second error. You cannot pass const parameter to operator >> as you will be modifying it. const means no modification allowed to object.

    Some other notes:

    QPair has assign operator so you don’t need to call

    upper.first = u.first;
    upper.second = u.second;
    

    instead use

    upper = u;
    

    There is also such thing as initialization list and you may assign it even like this:

    VisualSettings::VisualSettings(QPair<int, int> u, QPair<int, int> l)
        : upper(u)
        , lower(l)
    {
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created MutexCondition class like this /*MutexCondtion.h file*/ #ifndef MUTEXCONDITION_H_ #define MUTEXCONDITION_H_ #include
I have this file logger.hpp: #ifndef _LOGGER_HPP_ #define _LOGGER_HPP_ #include event.hpp // Class definitions
I have this include file ( memory .h ) #ifndef MEMORY_H #define MEMORY_H #ifdef
I have this definition for my Test class: #ifndef TEST_H #define TEST_H #include <iostream>
I have this abstract base class ODESolver: //ODESolver.h #ifndef ODESolver_H #define ODESolver_H #include doublependulum.h
I have Environment.h file: #include <windows.h> #include interfaces.h #ifndef ENVIRONMENT_H #define ENVIRONMENT_H class Environment
I have a header file like this: #ifndef __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__ #define __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__ #ifdef _DEBUG //
I have the following header file: #ifndef CLASSES_H #define CLASSES_H class Mouse // Handles
I have a file GetL.hxx #ifndef GetL_included #define GetL_included #include <iostream> using namespace std;
I have the following header file: #ifndef DATABASE_H #define DATABASE_H #include <vector> #include <iostream>

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.