- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在为我的应用程序设计一个需要动态滚动的 GUI,我正在使用 GTK(来自 Qt)并且我有以下代码:
Gtk::Window * wnd = new Gtk::Window();
Gtk::ScrolledWindow * scr = new Gtk::ScrolledWindow();
Gtk::Layout * lay = new Gtk::Layout();
Gtk::VBox * vbox = new Gtk::VBox();
wnd->add(*scr);
scr->add(*vbox);
for (int i = 0; i < 20; i++)
{
Gtk::Button * btn = new Gtk::Button();
btn->set_label("Click Me");
vbox->pack_start(*btn);
btn->show();
}
scr->set_kinetic_scrolling(true);
wnd->show();
scr->show();
lay->show();
vbox->show();
这就是你得到的:
这link告诉我以下内容:
void Gtk::ScrolledWindow::set_kinetic_scrolling ( bool kinetic_scrolling = true )
Turns kinetic scrolling on or off.
Kinetic scrolling only applies to devices with source Gdk::SOURCE_TOUCHSCREEN.
Since gtkmm 3.4:
Parameters kinetic_scrolling true to enable kinetic scrolling.
我尝试用鼠标捕获按钮并动态滚动,但正如预期的那样,它不起作用。我还没有触摸屏,我需要用我的鼠标进行试验,有什么方法可以做到这一点吗?
我还找到了 following :
enum InputSource {
SOURCE_MOUSE,
SOURCE_PEN,
SOURCE_ERASER,
SOURCE_CURSOR,
SOURCE_KEYBOARD,
SOURCE_TOUCHSCREEN,
SOURCE_TOUCHPAD,
SOURCE_TRACKPOINT,
SOURCE_TABLET_PAD
}
An enumeration describing the type of an input device in general terms.
有什么方法可以模拟设备类型吗?我希望看到它发挥作用。
最佳答案
你必须有一个触摸事件。使用 GtkInspector (Ctrl+Shift+I) 然后在 Visual 选项卡中,设置 Simulate touchscreen(如下图):
它应该可以工作。 More on Gtk Inspector
关于c++ - Gtk/Gtkmm 动态滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48594310/
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 2 年前。
我正在尝试使用 Gtkmm for C++、cairo::context、gdk::pixbuf 在窗口上绘图。我注意到对于某些宽度(在我的示例中为 298),我得到一些水平黑线(与白色条纹交替)而不
我刚刚从 gtkmm 2.4 更新了我的项目,我将在其中添加一个工具栏并通过以下方式将其更改为垂直: 工具栏.set_orientation(); 在 gtkmm 3.2 中,此功能不存在,我在“gt
我正在使用 Debian 8 并安装了 libgtkmm-3.0(以及 -dev)。现在我有一个使用 gtkmm 的非常简单的程序,基本上是一个 Hello World: 主要.cpp: #inclu
我需要将一个键盘按键事件附加到继承自 DrawingArea 的 Canvas。 我已经在构造函数中的“add_events()”上添加了这些事件,但运行后按键事件没有响应,出了什么问题? Canva
我希望在 Gtk::DrawableArea 上使用 mouseevents 画一条线。我想要的是这样的: 点击线路按钮激活线路事件 选择绘图区域中的第一个点(已绘制) 现在选择绘图区域中的第二个点(
操作系统:Debian 9.1 编译器:gcc(Debian 6.3.0-18) GTK+ 版本:3.22.11-1 Gtkmm 版本:3.22.0-1 大家好,我一直在用 Gtkmm 3.22.0-
我只是想知道小部件的大小。如果小部件的尺寸大于屏幕,我需要此信息将 ScrolledWindow 设置为最大尺寸。 但是我所知道的所有函数都给出一个常量值 1。 #include #include
我正在尝试使用 C++ 制作 GTK3 应用程序。因为它是我的第一个 gtkmm 应用程序而且它真的很小,所以我避免使用构建器并使用纯代码放置小部件。 我有这样的标题栏菜单按钮片段: Gtk::Men
在 gtkmm 中是否有防止窗口移动的好方法? 起初我尝试通过重载 on_configure_event(强行将窗口移动到固定位置)来做到这一点,但这导致了一些奇怪的图形故障和调整窗口大小时的巨大减速
我正在尝试编译 Gtkmm 书中的简单示例。我使用的代码在 simple.cc 文件中 #include int main(int argc, char *argv[]) { auto app =
我可以连接到什么事件来检测用户在窗口中时按下的箭头键。 到目前为止,我已尝试通过 on_key_press_event 进行连接,并检查了 keyval、hardware_keycode 和 stat
我必须创建一个简单的应用程序,在系统托盘中显示一个图标和一个菜单,您可以从中执行一些操作。问题是状态图标在创建后立即关闭。少了什么东西?我放置 sleep 以确保它已创建。系统托盘中出现了 3 秒钟的
我正在尝试用 gtkmm 编写程序,但按钮不会显示。我已尽我所能使这些按钮显示出来,但没有任何效果。我什至在主文件和 win_home.cpp 文件中都包含了“显示所有”方法,但仍然没有任何反应。然而
我试图在单击按钮时更改按钮的背景颜色。我已经很好地将按钮连接到点击方法,但我似乎无法找到正确的 c++ 语法来创建它。我已经看到它是用 python 完成的,但这并不能完全帮助我。有人有教程或知道语法
因为我正在编写一个在面对其他配置时表现完全不同的“通用”应用程序,所以我被迫显示 gtk 窗口,即使我在启动时还不知道它们。可能还需要同时显示多个窗口(不是模态对话框,而是独立窗口)。但是,如果可以在
你好 stackoverflow:),我正在编译一个基本的 gui 程序,它对 2 个 double 值求和并将它们打印出来。我的代码其实很简单,我先贴出我用命令行编译的3个文件 "g++ main.
我正在寻找一种暂停应用程序执行的方法,它不会被卡住,并且当用户按下按钮时,它会立即继续它暂停时正在做的任何事情。 我找不到任何关于此或如何将执行暂停一定时间的文档。有人可以帮我解决这个问题吗? 最佳答
我有以下问题:我创建了一个提示用户进行一些输入的程序。这是使用派生的 Gtk::Dialog 完成的,其用法如下: if (modal_dialog->run() == SUCCESS){ //
我没有代码错误,我只是到处看了看,不知道该怎么做。我想获得 Gtk::widget 的颜色,即 Gtk::label。我可以像这样覆盖标签的颜色: l.override_color( c, l.get
我是一名优秀的程序员,十分优秀!