Gtkmm - “Gtk :: DrawingArea”在“Gtk :: ScrolledWindow”? [英] Gtkmm - "Gtk::DrawingArea" in "Gtk::ScrolledWindow"?

查看:146
本文介绍了Gtkmm - “Gtk :: DrawingArea”在“Gtk :: ScrolledWindow”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用gtkmm制作GUI程序。
我想为Gtk :: DrawingArea小部件绘制一些图形,但是我想要该小部件是可调整大小的,所以当我画一个线从(0,0)到 50,50)像素 - 绘图区域应调整为大小为(50,50)的正方形;当我例如从(0,0)绘制一条线,让我们说(100,70)像素时 - 绘制区域应当被调整为大小为(100,70)的矩形。

I am making a GUI program using "gtkmm". I would like to draw some graphics to the "Gtk::DrawingArea" widget but I want that widget to be "resizable", so when I draw let's say a line from "(0, 0)" to "(50, 50)" pixel - the drawing area should be resized to a square of size "(50, 50)"; and when I for example draw a line from "(0, 0)" to let's say "(100, 70)" pixel - the drawing area should be resized to a rectangle of size "(100, 70)".

为此,我将Gtk :: DrawingArea小部件放入Gtk :: ScrolledWindow容器中。

And to do this - I put the "Gtk::DrawingArea" widget into the "Gtk::ScrolledWindow" container.

所以当我把一个大小为(100,100)的图片绘制区域 - >我会调用适当的成员函数Gtk :: DrawingArea :: set ___ size_request(100,100),将设置大小的绘图区域到(100,100)像素。因此,如果Gtk :: ScrolledWindow比Gtk :: DrawingArea更小,滚动窗口应该更改为可滚动 - 但问题是,它不工作!!!!!

So when I put a picture with size "(100, 100)" to the drawing area -> I will call the appropriate member function "Gtk::DrawingArea::set___size_request(100, 100)", which will set the size of the drawing area to (100, 100) pixels. So if the "Gtk::ScrolledWindow" is "smaller" than the "Gtk::DrawingArea" inside it, the scrolled window should change to "scrollable" - BUT THE PROBLEM IS, THAT IT DOES NOT WORK!!!!!

因此,任何人都可以解释我该如何做?

So could anybody explain me how can I do this?

谢谢。

推荐答案

在您的ScrolledWindow和DrawingArea之间添加GTK :: Viewport。

Add a GTK::Viewport in between your ScrolledWindow and DrawingArea.

这篇关于Gtkmm - “Gtk :: DrawingArea”在“Gtk :: ScrolledWindow”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆