Results 1 to 9 of 9

Thread: How to install and run old Qt4?

  1. #1
    Join Date
    Jul 2010
    Posts
    72
    Thanks
    35
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to install and run old Qt4?

    Hi everyone,

    I created an application a good while ago in Qt4. Recentrly I installed Qt5 and it won't run, displaying an error: error: QDialog: No such file or directory #include <QDialog>

    I did some google search and added 'QT += widgets' to the .pro file. Well this error was gone but 281 new errors featuring incompatilities with QLabels, etc appeared.

    I then decided to jump out of Qt 5 and go back to Qt4. This is where trouble starts: I installed the Qt4 libraries from http://qt-project.org/downloads but I cannot find a way of running actual Qt4 or, alternatively, running Qt5 using the Qt4 libraries.

    Any suggestions on how to get Qt4 to run on windows 7?

    Thank you.
    Maluko
    Last edited by Maluko_Da_Tola; 29th October 2013 at 11:41.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to install and run old Qt4?

    What was the 281 errors you were getting ? You could post a few.

    Also do mention the PATH and QTDIR values from your environment.

  3. The following user says thank you to aamer4yu for this useful post:

    Maluko_Da_Tola (30th October 2013)

  4. #3
    Join Date
    Jul 2010
    Posts
    72
    Thanks
    35
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to install and run old Qt4?

    Hi, here are a few examples:

    error: 'QLabel' does not name a type
    error: call of overloaded 'qRound(int)' is ambiguous
    error: forward declaration of 'class QPushButton'
    error: invalid use of incomplete type 'class QLabel'
    error: forward declaration of 'class QLabel'
    error: type 'QLabel' is not a direct base of 'microLabel'

    PATH: C:\Qt\Qt5.1.1\5.1.1\mingw48_32\bin; (I tried to add C:\Qt\4.7.4 to the PATH but the results were the same).
    QTDIR: C:\Qt\Qt5.1.1\5.1.1\mingw48_32; (I tried to replace this with C:\Qt\4.7.4 but it did not run the results were the same).

    Thank you,
    Maluko

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to install and run old Qt4?

    Sounds like you are missing includes for QLabel, QPushButton and so on.

    Since it builds with Qt4 one reason could be that you are using a module include and did not modify it, e.g. you have
    Qt Code:
    1. #include <QtGui>
    To copy to clipboard, switch view to plain text mode 
    and have not changed it to
    Qt Code:
    1. #include <QtWidgets>
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  6. The following user says thank you to anda_skoa for this useful post:

    Maluko_Da_Tola (30th October 2013)

  7. #5
    Join Date
    Jul 2010
    Posts
    72
    Thanks
    35
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to install and run old Qt4?

    Thank you anda_skoa: It worked! For anyone interested, I solved the error 'error: call of overloaded 'qRound(int)' is ambiguous' by assigning seting the argument to float using 'qRound(float(int))'

    Many thanks
    Maluko

  8. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to install and run old Qt4?

    Regardless of where this error is coming from, Rounding an integer makes no sense.

  9. #7
    Join Date
    Jul 2010
    Posts
    72
    Thanks
    35
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to install and run old Qt4?

    ChrisW67, rounding an integer seems to be pointless, indeed. However, that is not the issue: the argument of qRound() could be L/2, where L is an integer. So, if L is an odd number, L/2 is not an integer anymore. In Qt4 there was no problems, it would recognise that L/2 would not be an integer and would round it (so the sintax qRound(L/2) would produce no errors). In Qt5 I need to declare that explicitly by writing qRound(float(L/2)).

    Cheers
    Maluko

  10. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to install and run old Qt4?

    If you have int L then the expression L/2 results in an integer not a float.

    Qt4 has only one version of qRound() taking a double, so an implicit cast of integer to double is done and qRound(L/2) compiles cleanly (although you are still "rounding" an integer).
    Qt5 has two versions of qRound() taking float or double. Your compiler has raised the new error because it does not know whether to implicitly cast the integer value you have given qRound() to float or double.

    Casting to a float the way you have done does not achieve what you think it does. By the time you cast to float you have already done an integer division and discarded the fractional part. There's nothing for qRound() to round even if you then cast the integer result to float or double.
    Qt Code:
    1. int L = 5;
    2. qDebug() << L / 3; // 1, an integer division
    3. qDebug() << qRound(L / 3); // 1, still an integer division (will not compile under Qt5)
    4. qDebug() << qRound(float(L / 3)); // 1, converting the integer result to float still discards the fractional part
    5. qDebug() << qRound(L / 3.0); // 2, this is forcing floating point division
    6. qDebug() << qRound(qreal(L) / 3); // 2, also a floating point division
    To copy to clipboard, switch view to plain text mode 


    If you do revert to Qt4 then you will need a suitable tool chain. The Qt4 binaries distributed at the Qt Project site were built with MingW/GCC 4.4. You appear to be using the GCC 4.8 compiler. There are, if memory serves, binary interface differences between GCC 4.4 and 4.8 that might cause unexpected runtime issues if you mix Qt objects of the old and new binary formats. If you want to use the Qt4 binaries as-is you will need to match the GCC version.
    Last edited by ChrisW67; 30th October 2013 at 22:56.

  11. The following user says thank you to ChrisW67 for this useful post:

    Maluko_Da_Tola (30th October 2013)

  12. #9
    Join Date
    Jul 2010
    Posts
    72
    Thanks
    35
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to install and run old Qt4?

    Many thanks a few years away from c++/Qt and I had forgot about its peculiar algebra!

Similar Threads

  1. Replies: 0
    Last Post: 17th November 2011, 13:35
  2. Replies: 6
    Last Post: 13th March 2011, 23:49
  3. Replies: 4
    Last Post: 18th April 2010, 00:37
  4. How install fonts with make install
    By jiveaxe in forum Qt Programming
    Replies: 1
    Last Post: 2nd January 2008, 19:38
  5. "make install" doesn't install binary
    By jiveaxe in forum Newbie
    Replies: 2
    Last Post: 2nd January 2008, 12:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.