No viable conversion from 'const QString::Null' to 'QWidget *' Error help! [SOLVED]
-
wrote on 1 Mar 2014, 05:50 last edited by
Hello,
I'm not very familiar with qt but the software I'm trying to install requires it to build. After playing around with different versions all day, it would be really awesome if I could get any suggestions since I feel there could possibly be one line of code that needs tweaking. The code was written in the qt3 days, so I imagine it could be a version issue, and I couldn't get qt3 working on my Mavericks OSX.
I'm using qt 5.2.1. I'll include portions of the relevant code the errors point to at the bottom. Thanks in advance to anyone willing to have a look!
"In file included from main.cpp:7:
../egs_base_geometry.h:224:35: warning: unused parameter 'ireg' [-Wunused-parameter]
virtual EGS_Float getMass(int ireg) { return 1.0; }
^
../egs_base_geometry.h:231:36: warning: unused parameter 'idir' [-Wunused-parameter]
virtual EGS_Float getBound(int idir, int ind) {
^
../egs_base_geometry.h:231:46: warning: unused parameter 'ind' [-Wunused-parameter]
virtual EGS_Float getBound(int idir, int ind) {
^
../egs_base_geometry.h:240:32: warning: unused parameter 'idir' [-Wunused-parameter]
virtual int getNRegDir(int idir) { return 0; }
^
main.cpp:44:37: error: no viable conversion from 'const QString::Null' to 'QWidget *'
QFileDialog::getOpenFileName(QString::null,QString::null,0,0,
^~~~~~~~~~~~~
../../../../Qt5.2.1/5.2.1/clang_64/lib/QtCore.framework/Versions/5/Headers/qfiledialog.h:208:45: note: passing argument to parameter 'parent' here
static QString getOpenFileName(QWidget *parent = 0,
^
main.cpp:68:41: error: no member named 'latin1' in 'QString'
input.setContentFromFile(input_file.latin1());
~~~~~~~~~~ ^
4 warnings and 2 errors generated.
make[1]: *** [.obj/gfortran/main.o] Error 1
make: *** [all] Error 2"
Here is the relevant snippet of main.cpp:
"QString input_file = argc >= 2 ? argv[1] :
QFileDialog::getOpenFileName(QString::null,QString::null,0,0,
"Select geometry definition file");"Here is the relevant snipper of qfiledialog.h:
" static QString getOpenFileName(QWidget *parent = 0,
const QString &caption = QString(),
const QString &dir = QString(),
const QString &filter = QString(),
QString *selectedFilter = 0,
Options options = 0);"Here is the relevant snippet of
Thanks! -
Hi and welcome to devnet,
You are trying to pass a null QString in place of a QWidget or NULL, which is not the same. Replace your first QString::null with 0 and for the caption QString()
The minimal Qt version that you should use for Mavericks are 5.2 or 4.8.6. Qt 3 is way too old
-
wrote on 1 Mar 2014, 21:31 last edited by
Thank you SGaist for the reply, it solved that problem! I got through another two errors, however I now have 20 errors that all seem to be variations of the following:
".moc/gfortran/../../image_window.h:86:23: error: member access into incomplete type 'QMouseEvent'
else if( event->button() == Qt::LeftButton ) {
^
/Users/Rick/Qt5.2.1/5.2.1/clang_64/lib/QtWidgets.framework/Headers/qwidget.h:73:7: note: forward declaration of 'QMouseEvent'
class QMouseEvent; "Any ideas?
-
You are missing the QMouseEvent include
-
wrote on 1 Mar 2014, 22:50 last edited by
Thanks again SGaist, I'm truly grateful, your advice has been very helpful. I got through the rest of the errors, and arrived at another possibly linking error, which I'm thinking may be the last obstacle if it's a simple problem. Any advice?
"/HEN_HOUSE/egs++/view$ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -v -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.6 -o ../../bin/gfortran/egs_view.app/Contents/MacOS/egs_view .obj/gfortran/main.o .obj/gfortran/egs_visualizer.o .obj/gfortran/egs_track_view.o .obj/gfortran/moc_image_window.o -F/Users/Rick/Qt5.2.1/5.2.1/clang_64/lib -L../dso/gfortran -legspp -framework QtGui -framework QtCore -framework OpenGL -framework AGL
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.2
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -headerpad_max_install_names -macosx_version_min 10.6.0 -o ../../bin/gfortran/egs_view.app/Contents/MacOS/egs_view -lcrt1.10.6.o -L../dso/gfortran -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk .obj/gfortran/main.o .obj/gfortran/egs_visualizer.o .obj/gfortran/egs_track_view.o .obj/gfortran/moc_image_window.o -legspp -framework QtGui -framework QtCore -framework OpenGL -framework AGL -lstdc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.0/lib/darwin/libclang_rt.osx.a -F/Users/Rick/Qt5.2.1/5.2.1/clang_64/lib
Undefined symbols for architecture x86_64:
"QFileDialog::getOpenFileName(QString ()(), QString const&, QString const&, QString const&, QString const&, QFlagsQFileDialog::Option)", referenced from:
_main in main.o
"QApplication::exec()", referenced from:
_main in main.o
"QApplication::QApplication(int&, char**, int)", referenced from:
_main in main.o
"QApplication::~QApplication()", referenced from:
_main in main.o
"GeometryViewControl::setFilename(QString)", referenced from:
_main in main.o
"GeometryViewControl::setGeometry(EGS_BaseGeometry, std::vector<EGS_UserColor, std::allocator<EGS_UserColor> > const&, double, double, double, double, double, double, int)", referenced from:
_main in main.o
"GeometryViewControl::setTracksFilename(QString)", referenced from:
_main in main.o
"GeometryViewControl::GeometryViewControl(QWidget*, char const*, bool, QFlag)", referenced from:
_main in main.o
"GeometryViewControl::~GeometryViewControl()", referenced from:
_main in main.o
"QWidget::closeEvent(QCloseEvent*)", referenced from:
vtable for ImageWindow in moc_image_window.o
"QWidget::enterEvent(QEvent*)", referenced from:
vtable for ImageWindow in moc_image_window.o ..."
(it goes on)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)" -
Are you still using getOpenFileName in a wrong fashion ? Can you share the code ?
-
wrote on 1 Mar 2014, 23:12 last edited by
Of course!
QString input_file = argc >= 2 ? argv[1] :
QFileDialog::getOpenFileName(0,QString::null,0,0,
"Select geometry definition file"); -
You are trying to use the old Qt 3 getOpenFileName. Look at the documentation to see what to put where in the new version of the function
-
wrote on 1 Mar 2014, 23:38 last edited by
Okay, I decided to go another route and use macports to install qt3 and recompile. I'm about in the same place, I still get the "ld:symbol not found for architecture x86_64" message at the end, with only a few "Undefined Symbols" messages:
/usr/bin/clang++ -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib -arch x86_64 -prebind -o ../../bin/gfortran/egs_view .obj/gfortran/main.o .obj/gfortran/egs_visualizer.o .obj/gfortran/egs_track_view.o .obj/gfortran/viewcontrol.o .obj/gfortran/saveimage.o .obj/gfortran/clippingplanes.o .obj/gfortran/moc_image_window.o .obj/gfortran/moc_viewcontrol.o .obj/gfortran/moc_saveimage.o .obj/gfortran/moc_clippingplanes.o -L/opt/local/lib -L/opt/local/lib/qt3/lib -L/opt/local/lib -L/Users/Rick/egsnrc/HEN_HOUSE//egs++//dso/gfortran -legspp -lqt-mt -lXext -lX11 -lm
Undefined symbols for architecture x86_64:
"EGS_Input::takeInputItem(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)", referenced from:
_main in main.o
GeometryViewControl::reloadInput() in viewcontrol.o
"EGS_Input::getInput(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&) const", referenced from:
_main in main.o
GeometryViewControl::reloadInput() in viewcontrol.o
"EGS_Input::getInput(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, double&) const", referenced from:
_main in main.o
GeometryViewControl::reloadInput() in viewcontrol.old: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
-
What is EGS_Input ? Where does it come from ? Custom library ? Official library ?
-
wrote on 2 Mar 2014, 20:02 last edited by
Honestly, I'm not quite sure what you mean by custom vs official library, but it comes from the code I'm trying to compile and was written by its developers.
-
wrote on 2 Mar 2014, 20:10 last edited by
There is a class library included in my path, including egs_input.h
-
By custom I meant a library you wrote yourself and official some 3rd party like e.g. openssl.
So that that is 3rd party library, and from the look of it you only have it in 32bit, can you get it in 64 ?
-
wrote on 2 Mar 2014, 21:43 last edited by
No, unfortunately only 32 bit is available
-
Then you will need to first build Qt in 32bit
-
wrote on 3 Mar 2014, 21:05 last edited by
Thanks again SGaist. I tried that, still got more of the same error (had to compile with qt 5.2 again, can't install qt3 via macports).
Perhaps you could help me out with something else though, I'm compiling a different gui and receiving the error below. I recognize that it doesn't like either constructor, but given the relevant code in egs_tools.cpp (below), do you have any advice on how to change the definition of "target"?
Thanks again!
"../egs_install/src/egs_tools.cpp:255:15: error: call to constructor of 'std::ofstream' (aka 'basic_ofstream<char>') is ambiguous
std::ofstream out( target, ios::out | ios::binary );
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/fstream:1136:14: note: candidate constructor
explicit basic_ofstream(const char* __s, ios_base::openmode __mode = ios_base::out);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/fstream:1138:14: note: candidate constructor
explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out); "relevant snippet of egs_tools.cpp
" copies a char variable into a text file
/
bool copy2file(const char source, const QString& target)
{
std::ofstream out( target, ios::out | ios::binary );
if (!out) return false;
char ch;
while( *source ){
ch = *source;
source++;
out.put( ch );
}
out.close();
return true;
}" -
The first thing that surprises me is why use ofstream if you are using QString for copy2file ? You should use QFile and QDataStream, it would be simpler.
Anyway, you are trying to pass a QString to ofstream that expects a const char *, not a good idea. You need to convert the QString to a const char * (look at e.g. toLatin1())
Are you writing that EGS library ?
-
wrote on 3 Mar 2014, 23:07 last edited by
Thanks SGaist, that solved that problem. No, I am not writing this library, I am a user. This was written several years ago.
Still unfortunately not able to compile the other gui I described earlier, which had some kind of architecture x86_64 linker problem. I took your advice however and tried building qt3 in 32 bit. Since I could not build qt3 in 32 bit (I used macports to install it before, which gave the errors in my previous post.. I could not successfully build it from source), I built qt 5.2.1 in 32 bit using the ./configure -m32 option. This resulted in a the same error, "ld: symbol(s) not found for architecture x86_64."
-
wrote on 4 Mar 2014, 04:01 last edited by
Solved the problem by downgrading to a less recent Xcode version.. this was all unnecessary but I learned a bit and appreciate all your help!
Cheers! -
You're welcome !
Now that you got going, please update the thread title prepending [solved] so other forum users may know a solution has been found :)
1/20