how to print a file url using qDebug or other api to locate file in qtcreator?
-
wrote on 16 Nov 2021, 06:17 last edited by QtTester
-
Hi ,guys.
Usually i useqDebug() <<"my log:"<<__FILE__;
to output log.
But suddently I found qt core lib can print the file url and click the url qtcreator will locate the file. you can see the following image:So how to do that?
@QtTester said in how to print a file url using qDebug or other api to locate file in qtcreator?:
But suddently I found qt core lib can print the file url and click the url qtcreator will locate the file.
I really fail to understand what you're writing!
Can you please explain better?qDebug() << url;
-
@QtTester said in how to print a file url using qDebug or other api to locate file in qtcreator?:
But suddently I found qt core lib can print the file url and click the url qtcreator will locate the file.
I really fail to understand what you're writing!
Can you please explain better?qDebug() << url;
wrote on 16 Nov 2021, 06:27 last edited by@jsulm
well, when using:qDebug() << __FILE__;
we see the output looks like this:
..\..\..\..\Common\common\CommonLib\pluginmanager.cpp
but ,we cannot click the text !!!
in above image, the text..\..\MotionControlApp\motioncontrolapp.cpp:1337
is like a http url, we can click and jump to the file & line!
How can i achieve this? -
@jsulm
well, when using:qDebug() << __FILE__;
we see the output looks like this:
..\..\..\..\Common\common\CommonLib\pluginmanager.cpp
but ,we cannot click the text !!!
in above image, the text..\..\MotionControlApp\motioncontrolapp.cpp:1337
is like a http url, we can click and jump to the file & line!
How can i achieve this?@QtTester said in how to print a file url using qDebug or other api to locate file in qtcreator?:
but ,we cannot click the text !!!
Click where?
qDebug outputs the text at runtime in the console, I don't know what you want to click and where... -
@QtTester said in how to print a file url using qDebug or other api to locate file in qtcreator?:
but ,we cannot click the text !!!
Click where?
qDebug outputs the text at runtime in the console, I don't know what you want to click and where...wrote on 16 Nov 2021, 06:41 last edited by QtTester@jsulm
can you see my image? url is in the red circle.
Text:
........\Common\common\CommonLib\myfile.cpp
is printed as (for example):
<a href="c:\myfile.cpp">........\Common\common\CommonLib\myfile.cpp</a>
it can be clicked!
do you use android studio? AS also can print file url and you can quickly click to locate the file. -
@jsulm
can you see my image? url is in the red circle.
Text:
........\Common\common\CommonLib\myfile.cpp
is printed as (for example):
<a href="c:\myfile.cpp">........\Common\common\CommonLib\myfile.cpp</a>
it can be clicked!
do you use android studio? AS also can print file url and you can quickly click to locate the file.@QtTester said in how to print a file url using qDebug or other api to locate file in qtcreator?:
can you see my image?
No, I can't - it doesn't open.
If I understand you correctly this has nothing to do with qDebug(). You want to click on __FILE__ in QtCreator, right? But what should happen then? __FILE__ is the path of the source code file where you put it, but that file is already open (else you would not be able to click on it). So, what should happen? -
@QtTester said in how to print a file url using qDebug or other api to locate file in qtcreator?:
can you see my image?
No, I can't - it doesn't open.
If I understand you correctly this has nothing to do with qDebug(). You want to click on __FILE__ in QtCreator, right? But what should happen then? __FILE__ is the path of the source code file where you put it, but that file is already open (else you would not be able to click on it). So, what should happen?wrote on 16 Nov 2021, 06:57 last edited by QtTester@jsulm
You are right.
another image url if you can see it: https://ibb.co/4dTqKQc
If we can click the file and line.
QtCreator can quickly open the file and locate to the exactly line!
That will be much more help to us to debug!
only using FILE may be not the right choice. I am wondering how to do this. -
@jsulm
You are right.
another image url if you can see it: https://ibb.co/4dTqKQc
If we can click the file and line.
QtCreator can quickly open the file and locate to the exactly line!
That will be much more help to us to debug!
only using FILE may be not the right choice. I am wondering how to do this.@QtTester said in how to print a file url using qDebug or other api to locate file in qtcreator?:
QtCreator can quickly open the file and locate to the exactly line!
But it already does? I still don't understand what you want to do!
Again: where and when do you want to click?
During debugging in debugger?
Or do you want to click in Application Output tab in QtCreator? -
Hi ,guys.
Usually i useqDebug() <<"my log:"<<__FILE__;
to output log.
But suddently I found qt core lib can print the file url and click the url qtcreator will locate the file. you can see the following image:So how to do that?
@QtTester looking at the patch when this was added:
https://codereview.qt-project.org/c/qt-creator/qt-creator/+/251919
I would say,
qDebug().nospace() << "file://"<< __FILE__ << ":" << __LINE__;
-
wrote on 16 Nov 2021, 14:14 last edited by
Switch to the newer QObject::connect syntax and you will get an error at compile-time instead of run-time for the error you are seeing in your first screenshot. You will likely get more detailed info to help you fix your error. You probably have to
qobject_cast()
yourobj
to the correct class instead of just to aQObject
. -
@QtTester looking at the patch when this was added:
https://codereview.qt-project.org/c/qt-creator/qt-creator/+/251919
I would say,
qDebug().nospace() << "file://"<< __FILE__ << ":" << __LINE__;
wrote on 17 Nov 2021, 01:34 last edited by@J-Hilk said in how to print a file url using qDebug or other api to locate file in qtcreator?:
@QtTester looking at the patch when this was added:
https://codereview.qt-project.org/c/qt-creator/qt-creator/+/251919
I would say,
qDebug().nospace() << "file://"<< __FILE__ << ":" << __LINE__;
that's exactly what I want !
Thank you! -
@QtTester looking at the patch when this was added:
https://codereview.qt-project.org/c/qt-creator/qt-creator/+/251919
I would say,
qDebug().nospace() << "file://"<< __FILE__ << ":" << __LINE__;
wrote on 17 Nov 2021, 06:19 last edited by@J-Hilk
Still having a little confusion , in the output panel, the text:file://
will also be displayed. like:
mylong:file://..\mainwindow.cpp:47,very good
is there a way to hide "file://" ?
-
@J-Hilk
Still having a little confusion , in the output panel, the text:file://
will also be displayed. like:
mylong:file://..\mainwindow.cpp:47,very good
is there a way to hide "file://" ?
@QtTester to my knowledge
file://
is mandatory to mark it as a file linkI don't know how you would hide it.
1/13