简体   繁体   English

Qt 调试器输入不起作用

[英]Qt debugger input not working

I am trying to learn to debug using Qt Creator on OS X. Some of the exercises I am trying to complete require user input.我正在尝试学习在 OS X 上使用 Qt Creator 进行调试。我尝试完成的一些练习需要用户输入。 When run normally the terminal window appears and dialogue works fine.正常运行时会出现终端窗口并且对话正常。 However when run in debugger mode the terminal Windows down not appear and no input can be taken.但是,当在调试器模式下运行时,终端 Windows 不会出现并且无法进行任何输入。

I have tried setting a break point and setting the values using the "watches" window (I don't know what it is actually called but that is what Code:: Blocks called it).我试过设置断点并使用“手表”窗口设置值(我不知道它实际叫什么,但代码::块叫它)。 I have also tried to skip the cin lines using the step over button but that does not work either.我还尝试使用 step over 按钮跳过cin行,但这也不起作用。 I found this answer which seemed similar but it was for Ubuntu and I am on Mac and I have no idea how implement their fix.我发现这个答案看起来很相似,但它是针对 Ubuntu 的,我在 Mac 上,我不知道如何实施他们的修复。

Here is an example of my problem:这是我的问题的一个例子:

#include <iostream>
using namespace std;
int main ()
{
     double base_val;
     cout << "Enter a base value: ";
     cin >> base_val;
     //the code cannot go further than this
     cout << base_val;
}

This was done in a plain C++ application with the qmake build system.这是在带有qmake构建系统的普通 C++ 应用程序中完成的。 The Run in terminal option is checked (Projects / Build & Run /Run)选中 Run in terminal 选项(项目/构建和运行/运行)

I managed it to get it running on the qt creator and also with code::blocks but on arch linux - should work in windows and mac osx similar.我设法让它在qt creatorcode::blocks上运行,但在 arch linux 上运行 - 应该在 windows 和 mac osx 类似。

I installed gdb first but that is a Linux thing - windows and mac should have all on board ready installed with both editors.我首先安装了gdb,但那是 Linux 的东西——windows 和 mac 应该已经准备好安装了两个编辑器。 (yay -S gdb:) (是的 -S gdb :)

3 extra/gdb 8.3.1-1 (3.8 MiB 9.7 MiB) (Installed)
    The GNU Debugger

On Code::Blocks activate Debug->Debugging Windows->[x] Watches On the qt creator it is shown after hitting F5 or Debug->Start Debugging->Start Debugging of Startup Project F5 on the right hand side named name |在 Code::Blocks 激活Debug->Debugging Windows->[x] Watches在 qt 创建者上,它在点击F5Debug->Start Debugging->Start Debugging of Startup Project F5在名为name |的右侧 value价值

Both programs creates the same messages, took me a while - I hope that safes you guys time or helps you out if you never found it to这两个程序创建了相同的消息,花了我一段时间 - 我希望可以节省你们的时间,或者如果你从来没有发现它可以帮助你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM