Recently I got all excited on my progress with C++. Sometimes when there’s a blocker in your way and you can’t tackle it with your current knowledge then it’s time to sit, and think of a different strategy. In my case it was a case of selfishness and petty design that led me to this convoluted design in the application I’ve been working on.

I use most of what Qt offers me in terms of resources, all the classes for maximum compatibility between platforms. In this case I wanted to do this “pretty” design where everything is handled by different classes. There’s a catch, you meet “unexpected” corner cases where you just set scratching your head wondering why is it like that.

I have a class, let’s call it A:

class A : public QObject
{
    Q_OBJECT
public:
    A(QNetworkAccessManager* nam);
    ~A();
    void process();

private:
    QNetworkAccessManager* nam;
    void processFeed(FetcherReply* fetched);

public slots:
    void finished();

};

So when I put it in a Qt container

QList<A> list;
list << A(nam);

It happens that there’s a implicitly deleted copy constructor on behalf of QObject, which the documentation covers everything so far. Later on I work on a solution of just declaring the copy constructor myself and copying QNetworkAccessManager pointer to the copied class. It happens that that doesn’t go well because NAM doesn’t allow it.

Like I’ve said before, I’m really green behind the ears when it comes to these types of issue. I think part of the problem was thinking of some sort of grand design for the application when I should have aimed for a simple and flexible design rather than going Java.

C++ is undeniably full of surprises. This problem took me a while to admit defeat because I hate admitting defeat. I did learn some things to be aware of later on. Yet, I’m sad that I couldn’t break through the issue myself.

The road to become something decent is thorny as hell.