【问题标题】:Fltk Window waitFltk 窗口等待
【发布时间】:2011-11-22 18:09:52
【问题描述】:

C++ fltk:我有一个带有 in_box 和 out_box 的窗口,我如何制作它以便用户可以在 in_box 中键入回车,然后继续进行其余的事件。现在,窗口刚刚出现并消失。

Window w(Point(100,100),200,200, "Category Sales");
In_box cat_in(Point(75,75),100,20,"Category:");
Out_box cat_out(Point(75,115),100,20,"Sales:");
w.attach(cat_in);
w.attach(enter);
category = cat_in.get_string();

【问题讨论】:

    标签: c++ user-interface fltk


    【解决方案1】:

    我不确定这是否能解决您的问题,但要保持窗口打开,请返回 Fl::run()。

    【讨论】:

      【解决方案2】:

      我以前从未见过 In_box 和 Out_box,所以我假设它们是您自己的类或结构... 如前所述 - 启动 FLTK 事件循环的最简单方法是使用 Fl::run() 或 (FLTK2) fltk::run()。

      因此,您的代码应类似于 (FLTK2):

      #include <fltk/Window.h>
      #include <fltk/Widget.h>
      #include <fltk/run.h>
      
      using namespace fltk;
      
      int main(int argc, char **argv) {
      
        // your code begins
        Window w(Point(100,100),200,200, "Category Sales");
        In_box cat_in(Point(75,75),100,20,"Category:");
        Out_box cat_out(Point(75,115),100,20,"Sales:");
        w.attach(cat_in);
        w.attach(enter);
        category = cat_in.get_string();
        // your code ends
      
        w->end();
        w->show(argc, argv);
        return run(); // this line is the most important, here we start the FLTK event-loop
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-12-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-05-18
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多