[SOLVED] QT5 for Debian Linux



  • Hello,

    I need QCryptographicHash.addData() -function to accept a QIODevice (QFile). This can be done with Qt5. Sadly, Qt5 isn't officially released for Debian (I mean you can't get it with apt-get install...)

    I found this: http://packages.debian.org/sid/qt5-default

    How can I use it? If I simply:

    @apt-get install qt5-default@

    I get an error:

    @E: Unable to locate package qt5-default@

    Now I suppose this is because it's not an official package, and I need to add it to /etc/apt/sources.list. Problem is, I don't know how? Has someone used this package, how can I install it?

    Thank you in advance!


  • Lifetime Qt Champion

    Hi,

    If I saw things correctly, Qt 5 is available in the testing repositories (currently known as Jessie)

    You should either install a debian based on Jessie (so you only use packages from it) or add the repositories from Jessie in your sources.list (copy the lines from stable and change the target to testing), sync and install Qt 5

    Hope it helps



  • [quote author="SGaist" date="1388612048"]Hi,

    If I saw things correctly, Qt 5 is available in the testing repositories (currently known as Jessie)

    You should either install a debian based on Jessie (so you only use packages from it) or add the repositories from Jessie in your sources.list (copy the lines from stable and change the target to testing), sync and install Qt 5

    Hope it helps[/quote]

    Thank you for your answer.

    The problem is, I don't really know much about editing sources.list.. I've read about it some, from here: https://wiki.debian.org/SourcesList, but I don't understand:

    1. Which URL should I use? I tried http://anonscm.debian.org/gitweb/?p=pkg-kde/qt/qtbase.git;a=summary, which I found from http://packages.debian.org/source/sid/qtbase-opensource-src, is it right?
    2. Which distribution (after your post, I guess it's jessie?)
    3. What about component1 - 3, do I need to add them?

    Thank you in advance again!


  • Lifetime Qt Champion

    There's the "Example sources.list for Debian 7 "Wheezy"" that you can follow, just substitute Wheezy with Jessie



  • Yes, but I still don't understand which URL I shoud use. If I add:

    @
    deb http://anonscm.debian.org/gitweb/?p=pkg-kde/qt/qtbase.git;a=summary jessie main@

    and run apt-get update, I get errors:

    @
    W: Failed to fetch http://anonscm.debian.org/gitweb/?p=pkg-kde/qt/qtbase.git;a=summary/dists/jessie/main/binary-amd64/Packages Error reading from server. Remote end closed connection
    W: Failed to fetch http://anonscm.debian.org/gitweb/?p=pkg-kde/qt/qtbase.git;a=summary/dists/jessie/main/i18n/Translation-en Error reading from server. Remote end closed connection
    @

    Now, I assume this is because I'm not using the corrent url? What is the correct url? Is my entry to the sources.list correct, excluding the url? Sorry for probably asking stupid questions, I've tried to Google and tested stuff myself, but can't figure it out..


  • Lifetime Qt Champion

    Change Wheezy example:
    @deb http://http.debian.net/debian wheezy main@

    to Jessie:

    @deb http://http.debian.net/debian jessie main@



  • Heh, okay now I got it.. So I wasn't even supposed to be adding anything, just modifying the existing entry.

    Thank you for your help, it's now installing :)



  • Damn, actually it's not solved.. Well, Qt5 is now installed:

    @
    $ qtchooser -print-env
    QT_SELECT="default"
    QTTOOLDIR="/usr/lib/x86_64-linux-gnu/qt5/bin"
    QTLIBDIR="/usr/lib/x86_64-linux-gnu"

    $ qmake -v
    QMake version 3.0
    Using Qt version 5.1.1 in /usr/lib/x86_64-linux-gnu
    @

    But if I try to compile function:

    @QString hashFile(QString filename, QCryptographicHash::Algorithm a)
    {
    QFile *f = new QFile(filename);
    if (f->open(QIODevice::ReadOnly))
    {
    QCryptographicHash *hash = new QCryptographicHash(a);

        hash->addData(f);
        QByteArray result = hash->result();
        f->close();
        return QString(result.toHex());
    }
    else
    {
        logentry("Could not open file " + filename.toStdString() + " for generating MD5 hash, error: " + f->errorString().toStdString(), logs::ERRORS, logs::ID_ERROR);
        return QString();
    }
    

    }@

    on my Linux machine, I get error:

    @basic_functions.cpp: In function 'QString hashFile(QString, QCryptographicHash::Algorithm)':
    basic_functions.cpp:243:24: error: no matching function for call to 'QCryptographicHash::addData(QFile*&)'
    basic_functions.cpp:243:24: note: candidates are:
    In file included from /usr/include/qt4/QtCore/QCryptographicHash:1:0,
    from basic_functions.h:8,
    from basic_functions.cpp:1:
    /usr/include/qt4/QtCore/qcryptographichash.h:69:10: note: void QCryptographicHash::addData(const char*, int)
    /usr/include/qt4/QtCore/qcryptographichash.h:69:10: note: candidate expects 2 arguments, 1 provided
    /usr/include/qt4/QtCore/qcryptographichash.h:70:10: note: void QCryptographicHash::addData(const QByteArray&)
    /usr/include/qt4/QtCore/qcryptographichash.h:70:10: note: no known conversion for argument 1 from 'QFile*' to 'const QByteArray&'
    make: *** [basic_functions.o] Error 1
    @

    It compiles fine on my Windows machine, with Qt5.1.1 installed aswell.

    EDIT: Also noticed a memory leak in my function, will fix that...


  • Lifetime Qt Champion

    You project is still using Qt 4. If using Qt Creator, change the kit to use Qt 5, on the command line, clean your build and re-run qmake



  • Ah, thank you. I'm not using Qt Creator on my Linux machine, I'm compiling from terminal. I ran make clean and qmake, and after that the it compiled fine!

    Now it's solved :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.