Results 1 to 17 of 17

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

  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.

  6. #6
    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
    sounds like you have got too many Qt installs are are mixing up library binaries?
    nope, qt4.7 is on a ubuntu 10.10, 4.8 in a vm with 12.04... where I am trying to get it run, and there is definitely no second qt installed..


    Added after 8 minutes:


    Quote Originally Posted by amleto View Post

    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.
    As I said, I am not familiar with qt, but I guess I have to edit the Reveal.pro file, which has these contents: http://paste.ubuntu.com/1370379


    Added after 12 minutes:


    ok, I installed qt debugging symbols, and without recompliation, it now tells :

    Qt Code:
    1. (gdb) run
    2. Starting program: /home/hero/Downloads/clay_2006_10_17/projects/Reveal
    3. [Thread debugging using libthread_db enabled]
    4. Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
    5. [New Thread 0x7fffe8bc5700 (LWP 8387)]
    6. [New Thread 0x7fffe3fff700 (LWP 8388)]
    7.  
    8. Program received signal SIGSEGV, Segmentation fault.
    9. QString::fromLocal8Bit (str=0x21 <Address 0x21 out of bounds>, size=-1) at tools/qstring.cpp:3960
    10. 3960 tools/qstring.cpp: No such file or directory.
    To copy to clipboard, switch view to plain text mode 

    and I cannot find a qstring.cpp file on my 12.04 system


    hmm, recompiling with CONFIG+= qt debug added to Reveal.pro created the debugging symbols for Reveal, but did not change the gdb output...
    Last edited by cr3005; 19th November 2012 at 16:56.

  7. #7
    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

    "I installed qt debuggung symbols"
    I don't know what this means.

    Did you recompile Qt on your 12.04 sys?

    Can't you run the debugger and obtain the stack trace?


    *What is most useful information is the last line of your code that is executed before the seg fault, and the value of all variables at that stack level*
    That's basic information for diagnosing seg faults like this.
    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.

  8. #8
    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
    "I installed qt debuggung symbols"
    I don't know what this means.

    Did you recompile Qt on your 12.04 sys?

    Can't you run the debugger and obtain the stack trace?
    I thought that download and install the libqt4-dbg package (319mb size) would actually install the debugging symbols for all qt libraries?

    sorry, I am a bit rusty with all that, here is the bt:
    Qt Code:
    1. (gdb) run
    2. Starting program: /home/hero/Downloads/clay_2006_10_17/projects/Reveal
    3. [Thread debugging using libthread_db enabled]
    4. Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
    5. [New Thread 0x7fffe8bc5700 (LWP 8637)]
    6. [New Thread 0x7fffe3fff700 (LWP 8638)]
    7.  
    8. Program received signal SIGSEGV, Segmentation fault.
    9. QString::fromLocal8Bit (str=0x21 <Address 0x21 out of bounds>, size=-1) at tools/qstring.cpp:3960
    10. 3960 tools/qstring.cpp: No such file or directory.
    11. (gdb) bt
    12. #0 QString::fromLocal8Bit (str=0x21 <Address 0x21 out of bounds>, size=-1) at tools/qstring.cpp:3960
    13. #1 0x00007ffff5f6ec8b in QCoreApplication::arguments () at kernel/qcoreapplication.cpp:2235
    14. #2 0x00007ffff685cda0 in sm_performSaveYourself (smd=0x6ffdb0) at kernel/qapplication_x11.cpp:6078
    15. #3 0x00007ffff685d989 in sm_saveYourselfCallback (smcConn=<optimized out>, clientData=<optimized out>, saveType=<optimized out>,
    16. shutdown=<optimized out>, interactStyle=<optimized out>) at kernel/qapplication_x11.cpp:6061
    17. #4 0x00007ffff3faadff in _SmcProcessMessage () from /usr/lib/x86_64-linux-gnu/libSM.so.6
    18. #5 0x00007ffff3d9cfd6 in IceProcessMessages () from /usr/lib/x86_64-linux-gnu/libICE.so.6
    19. #6 0x00007ffff5f81281 in QMetaObject::activate (sender=0x705c90, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7fffffffd720)
    20. at kernel/qobject.cpp:3547
    21. #7 0x00007ffff5fce2fe in QSocketNotifier::activated (this=<optimized out>, _t1=15) at .moc/release-shared/moc_qsocketnotifier.cpp:103
    22. #8 0x00007ffff5f8a60b in QSocketNotifier::event (this=0x705c90, e=0x7fffffffdd40) at kernel/qsocketnotifier.cpp:317
    23. #9 0x00007ffff67db894 in notify_helper (e=0x7fffffffdd40, receiver=0x705c90, this=0x6a18d0) at kernel/qapplication.cpp:4559
    24. #10 QApplicationPrivate::notify_helper (this=0x6a18d0, receiver=0x705c90, e=0x7fffffffdd40) at kernel/qapplication.cpp:4531
    25. #11 0x00007ffff67e0713 in QApplication::notify (this=0x7fffffffdfc0, receiver=0x705c90, e=0x7fffffffdd40) at kernel/qapplication.cpp:4420
    26. #12 0x00007ffff5f6ce9c in QCoreApplication::notifyInternal (this=0x7fffffffdfc0, receiver=0x705c90, event=0x7fffffffdd40)
    27. at kernel/qcoreapplication.cpp:876
    28. #13 0x00007ffff5f9ba97 in sendEvent (event=0x7fffffffdd40, receiver=<optimized out>)
    29. at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231
    30. #14 socketNotifierSourceDispatch (source=0x6a4b90) at kernel/qeventdispatcher_glib.cpp:110
    31. #15 0x00007ffff4908d53 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
    32. #16 0x00007ffff49090a0 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
    33. #17 0x00007ffff4909164 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
    34. #18 0x00007ffff5f9c3bf in QEventDispatcherGlib::processEvents (this=0x6a3640, flags=...) at kernel/qeventdispatcher_glib.cpp:424
    35. #19 0x00007ffff6883d5e in QGuiEventDispatcherGlib::processEvents (this=<optimized out>, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
    36. #20 0x00007ffff5f6bc82 in QEventLoop::processEvents (this=<optimized out>, flags=...) at kernel/qeventloop.cpp:149
    37. #21 0x00007ffff5f6bed7 in QEventLoop::exec (this=0x7fffffffdf50, flags=...) at kernel/qeventloop.cpp:204
    38. #22 0x00007ffff5f70f67 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1148
    39. #23 0x00000000004131de in main ()
    To copy to clipboard, switch view to plain text mode 


    As I have fiddled around on command-line only until now, I will have to install qt creator to debug this properly I guess. I just thought it wasn't necessary, as the program works fine with qt4.7...

    The problem is that I have to include an old version of exiv2 to get the program to work, and I know how to set paths and environment variables right to do so on command line, but all these things do not work when using qt-creator, so I am stuck, as I would have to learn how to edit pri files to add library paths etc..
    Last edited by cr3005; 19th November 2012 at 17:09.

  9. #9
    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

    I don't know how 'installing' qt works on nix. I would be surprised if you didn't need to compile it since it is not known what compiler you will be using...

    I don't see any of your code in that call stack. That points even more to bad build/linking.
    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.

  10. #10
    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

    oh well trust me, that's alright and works fine.

    But I actually have no clue why the back-trace is as is, without mentioning the code of the program.. as you say.

    That points even more to bad build/linking.
    I am shure that, compiling-wise, from qt standpoint, everything is as it should be. the right libraries are installed. the right things happen at compile-time, it compiles through. All things I have adapted compile-wise are because of an older exiv2 library needed by the program.

  11. #11
    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

    Quote Originally Posted by cr3005 View Post
    All things I have adapted compile-wise are because of an older exiv2 library needed by the program.
    The tail wagging the dog

    likely suspects
    1) mis-matched compiler
    2) mis-matched run times
    3) mis-matched debug/release binaries
    4) mis-matched compiler options
    5) something messing with that char* memory location
    6) ?


    Have you built the examples in 12.04? How well do the examples work?


    ps, your call stack looks like a release build...
    Last edited by amleto; 19th November 2012 at 19:33.
    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.

  12. #12
    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

    you actually underestimate the linux packaging system; it reliefs you from the burden of thinking about such details, and compiling a separate qt makes no sense, as I want that little app (under 2 mb with supported libraries) have to stay little; If I do not get it to run, I can just pack qt4.7 libs into a folder and it runs. but that would be a waste of space. And for my purpose, space is the thing I really do not want to waste.


    the release build is 720kb, the debug build 4.5mb..
    here you can see that the debugging symbols are loaded: http://paste.ubuntu.com/1370858
    Last edited by cr3005; 19th November 2012 at 19:47.

  13. #13
    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

    Quote Originally Posted by amleto View Post

    Have you built the examples in 12.04? How well do the examples work?
    ^^^^^^^^^^^^
    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.

  14. #14
    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
    ^^^^^^^^^^^^
    ok will try.


    Added after 18 minutes:


    Actually found the solution. What a good sleep can make a difference

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


    thanks for all anyways to kindly give me a bit of your time.
    Last edited by cr3005; 20th November 2012 at 07:10.

  15. #15
    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

    That's not the solution. That's not even *a* solution. That's a work-around.

    and you never tried my suggestion of ... = ""; instead of ... = QString(); I would be interested to know if that works or not.
    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.

  16. #16
    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

    Quote Originally Posted by amleto View Post
    and you never tried my suggestion of ... = ""; instead of ... = QString(); I would be interested to know if that works or not.
    That would be almost the same. Assigning "" creates and empty non-null string (isEmpty() && !isNull()), assigning QString() creates and empty, null string (isEmpty() && isNull()).

    The clear() calls in the code snippet are basically no-ops, because the string is a null string, so clearing it doesn't change anything.

    One other difference between assigning "" and assigning QString() is that the latter will always compile, while the former needs QString( const char * ) to be available which is not the case if the code is built with Q_NO_CAST_FROM_ASCII

    Cheers,
    _

  17. #17
    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

    Quote Originally Posted by anda_skoa View Post
    That would be almost the same. Assigning "" creates and empty non-null string (isEmpty() && !isNull()), assigning QString() creates and empty, null string (isEmpty() && isNull()).
    Yes, I know. Almost being the key word. Maybe there is some eliding in one that doesn't happen in the other.

    The clear() calls in the code snippet are basically no-ops, because the string is a null string, so clearing it doesn't change anything.
    If this is the only difference and 'fixes' the issue, then it cannot be a no-op

    thanks for, well, stating the obvious I guess.
    Last edited by amleto; 20th November 2012 at 19:37.
    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.