Results 1 to 17 of 17

Thread: trying to port an application to qt4.8 : qstring ambigous error

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2012
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default trying to port an application to qt4.8 : qstring ambigous error

    hello

    I have this little cool application, reveal, which is a exif metadata viewer. It is from 2006, coded with qt4. Apart from some minor adjustments, it compiles until

    Qt Code:
    1. g++ -c -pipe -O2 -O2 -I/usr/include -D_REENTRANT -Wall -W -DBIN_DIR=\""/usr/bin\"" -DRESOURCE_DIR=\""/usr/share/Reveal\"" -DTARGET=\""Reveal\"" -DNEEDED_TRANSLATIONS=\""Reveal commonDialogs generalTools qt\"" -DQT_NO_DEBUG -DQT_XML_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtXml -I/usr/include/qt4 -Itmp -o tmp/dynamicSlider.o ../src/_commonWidgets/dynamicSlider.cpp
    2. ../src/_commonWidgets/dynamicSlider.cpp: In member function 'void DynamicSlider::setPrefix(QString)':
    3. ../src/_commonWidgets/dynamicSlider.cpp:54:27: error: call of overloaded 'QString(NULL)' is ambiguous
    4. /usr/include/qt4/QtCore/qstring.h:428:43: note: candidates are: QString::QString(const QByteArray&)
    5. /usr/include/qt4/QtCore/qstring.h:426:43: note: QString::QString(const char*)
    6. /usr/include/qt4/QtCore/qstring.h:727:8: note: QString::QString(const QString&)
    7. /usr/include/qt4/QtCore/qstring.h:106:5: note: QString::QString(QChar)
    8. /usr/include/qt4/QtCore/qstring.h:105:14: note: QString::QString(const QChar*)
    9. ../src/_commonWidgets/dynamicSlider.cpp: In member function 'void DynamicSlider::setSuffix(QString)':
    10. ../src/_commonWidgets/dynamicSlider.cpp:68:27: error: call of overloaded 'QString(NULL)' is ambiguous
    11. /usr/include/qt4/QtCore/qstring.h:428:43: note: candidates are: QString::QString(const QByteArray&)
    12. /usr/include/qt4/QtCore/qstring.h:426:43: note: QString::QString(const char*)
    13. /usr/include/qt4/QtCore/qstring.h:727:8: note: QString::QString(const QString&)
    14. /usr/include/qt4/QtCore/qstring.h:106:5: note: QString::QString(QChar)
    15. /usr/include/qt4/QtCore/qstring.h:105:14: note: QString::QString(const QChar*)
    16. make: *** [tmp/dynamicSlider.o] Error 1
    To copy to clipboard, switch view to plain text mode 


    where the file looks like this:

    Qt Code:
    1. void DynamicSlider::setPrefix( QString val )
    2. {
    3. prefix1 = val;
    4. prefix2 = QString( NULL );
    5. updateTooltipLabel();
    6. }
    7. //==========================================
    8. void DynamicSlider::setPrefixes( QString v1, QString v2 )
    9. {
    10. prefix1 = v1;
    11. prefix2 = v2;
    12. updateTooltipLabel();
    13. }
    14. //==========================================
    15. void DynamicSlider::setSuffix( QString val )
    16. {
    17. suffix1 = val;
    18. suffix2 = QString( NULL );
    19. updateTooltipLabel();
    20. }
    To copy to clipboard, switch view to plain text mode 

    and .h

    Qt Code:
    1. ///set two prefix values, one for when the value is positive and one for when the value is negative.
    2. void setPrefixes( QString prefix1, QString prefix2 );
    3.  
    4. ///set the suffix that is displayed after the current slider value
    5. void setSuffix( QString val );
    6.  
    7. ///set two suffix values, one for when the value is positive and one for when the value is negative.
    8. void setSuffixes( QString suffix1, QString suffix2 );
    To copy to clipboard, switch view to plain text mode 


    Now, with qt4.7, when I delete the NULL, it compiles through and runs.

    With qt 4.8, I get a segmentation fault, gdb tells it faults in Qstring::fromLocal8Bit(char const*, int) ()

    I am not familiar with qt, could somebody help me out?

    thx in advance

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: trying to port an application to qt4.8 : qstring ambigous error

    just replace

    QString(NULL)

    with

    ""


    e.g.
    Qt Code:
    1. suffix2 = "";
    To copy to clipboard, switch view to plain text mode 
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    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: trying to port an application to qt4.8 : qstring ambigous error

    Just replace QString( NULL ) with QString() or call the string variable's clear() method.

    Cheers,
    _

  4. #4
    Join Date
    Nov 2012
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: trying to port an application to qt4.8 : qstring ambigous error

    Quote Originally Posted by amleto View Post
    just replace

    QString(NULL)

    with

    ""


    e.g.
    Qt Code:
    1. suffix2 = "";
    To copy to clipboard, switch view to plain text mode 
    hmm, nope, just keeps segfaulting...


    Added after 6 minutes:


    Quote Originally Posted by anda_skoa View Post
    Just replace QString( NULL ) with QString()

    Cheers,
    _
    As I stated in my beginning post, I DID replace QString( NULL ) with QString() and it compiled through, but it segfaults with 4.8...
    0x00007ffff5eb5b40 in Qstring::fromLocal8Bit(char const*, int) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4

    or call the string variable's clear() method.
    will try that, if I find out how...
    Last edited by cr3005; 19th November 2012 at 15:53.

  5. #5
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: trying to port an application to qt4.8 : qstring ambigous error

    sounds like maybe you have got too many Qt installs are are mixing up library binaries?

    but since you have a runtime error, the issue is not likely to be syntax problem... More probable is data/value problem. Since you didnt show how that segfault is traced from your code, you are not making things easy to diagnose.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. Replies: 3
    Last Post: 27th July 2012, 09:30
  2. Replies: 2
    Last Post: 11th August 2011, 15:42
  3. Replies: 1
    Last Post: 30th May 2011, 13:46
  4. port application from 2.3 to 4.5
    By baumbech in forum Qt Programming
    Replies: 1
    Last Post: 24th September 2009, 07:42
  5. Replies: 1
    Last Post: 18th March 2009, 14:29

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.