gpt4 book ai didi

c++ - Gtk/Gtkmm 动态滚动

转载 作者:太空狗 更新时间:2023-10-29 20:51:46 25 4
gpt4 key购买 nike

我正在为我的应用程序设计一个需要动态滚动的 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();

这就是你得到的:

enter image description here

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(如下图):

enter image description here

它应该可以工作。 More on Gtk Inspector

关于c++ - Gtk/Gtkmm 动态滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48594310/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com