Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to print a file url using qDebug or other api to locate file in qtcreator?
Forum Updated to NodeBB v4.3 + New Features

how to print a file url using qDebug or other api to locate file in qtcreator?

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 4 Posters 806 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • jsulmJ jsulm

    @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;
    
    Q Offline
    Q Offline
    QtTester
    wrote on last edited by
    #3

    @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?

    jsulmJ 1 Reply Last reply
    0
    • Q QtTester

      @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?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #4

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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      Q 1 Reply Last reply
      0
      • jsulmJ jsulm

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

        Q Offline
        Q Offline
        QtTester
        wrote on last edited by QtTester
        #5

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

        jsulmJ 1 Reply Last reply
        0
        • Q 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.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by jsulm
          #6

          @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?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          Q 1 Reply Last reply
          0
          • jsulmJ jsulm

            @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?

            Q Offline
            Q Offline
            QtTester
            wrote on last edited by QtTester
            #7

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

            jsulmJ 1 Reply Last reply
            0
            • Q 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.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #8

              @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?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • Q QtTester

                Hi ,guys.
                Usually i use

                qDebug() <<"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:

                alt text

                So how to do that?

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by
                #9

                @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__;
                

                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                Q 2 Replies Last reply
                3
                • M Offline
                  M Offline
                  mchinand
                  wrote on last edited by
                  #10

                  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() your obj to the correct class instead of just to a QObject.

                  1 Reply Last reply
                  1
                  • J.HilkJ J.Hilk

                    @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__;
                    
                    Q Offline
                    Q Offline
                    QtTester
                    wrote on last edited by
                    #11

                    @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!

                    1 Reply Last reply
                    1
                    • J.HilkJ J.Hilk

                      @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__;
                      
                      Q Offline
                      Q Offline
                      QtTester
                      wrote on last edited by
                      #12

                      @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.HilkJ 1 Reply Last reply
                      0
                      • Q QtTester

                        @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.HilkJ Offline
                        J.HilkJ Offline
                        J.Hilk
                        Moderators
                        wrote on last edited by
                        #13

                        @QtTester to my knowledge file:// is mandatory to mark it as a file link

                        I don't know how you would hide it.


                        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                        Q: What's that?
                        A: It's blue light.
                        Q: What does it do?
                        A: It turns blue.

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved