c++fltk

Why FLTK window become unresizable with mouse after resize() was called?


Why I cannot resize the window once window.size() or window.resize() was called? How to fix this?

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
int main(int argc, char** argv) {
  Fl_Window window(0, 0, 110, 110);
  window.position(0, 0);
//  window.size(300, 300); <--uncomment this, and cannot resize window with the mouse!
  window.show(argc,argv);
  return Fl::run();
}
 

Solution

  • size(width, height) is basically a shortcut to resize(x(), y(), width, height). It fixes the size of the widget.

    If you want the window to be resizable, call

    window.resizable(&window);
    

    Have a look at subwindow.cxx in the test programs from the distribution tarball.