- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在为学校的一个类(class)制作一个数独游戏,您可能已经猜到我正在使用带有 C++ 的 wxWidgets。
我的问题是,当我想在方 block 中创建一个具有不同值的新板时,我不知道如何刷新程序。
我使用 createBoard 函数创建板:
//Storing a random-generated sudokuboard into "board".
setBoard(board);
// sizers for the layout of bricks and buttons
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL); // overall layout
// 9 rows and 9 columns with fixed height and width
wxGridSizer *gs = new wxGridSizer(9, 9, 1, 1);
wxBoxSizer *hbox2 = new wxBoxSizer(wxHORIZONTAL); // button commands
// Define font and font size for the text in the squares
// Define valid input values for the text in the squares
csCharCtrl::Initialize(wxT("123456789"), sz);
// Create the squares
for (int i = 0; i < 81; i++) {
m_square[i] = CreateSquare(this, i+1, i/9, i%9);
// install an event handler for Set Focus event for the square
gs->Add(m_square[i], 0, wxEXPAND);
}
Bind(wxEVT_CHILD_FOCUS, &BoardPanel::OnChildFocus, this);
// buttons commands
// Check command
wxButton *btnnew = new wxButton(this, ID_New, wxT("New board"));
btnnew->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &BoardPanel::OnNew, this);
hbox2->Add(btnnew, 2, wxEXPAND);
vbox->Add(gs, 1, wxALIGN_CENTER | wxALL, 20);
vbox->Add(hbox2, 0, wxALIGN_CENTER | wxALL, 20);
SetSizer(vbox);
setBoard 在多维 vector 中生成一个新的数独游戏。
我有一个按钮正在监听我的点击,我希望它通过再次调用 setBoard 并在点击时刷新面板来创建一个新面板。
我该怎么做?
我的按钮代码很简单:
void BoardPanel::OnClick(wxCommandEvent& WXUNUSED(event)){
//CODE onClick
}
这是程序的图片:
最佳答案
我想 m_square[i]
是 wxTextCtrl*
或类似的东西。在 OnClick
事件处理程序中,在 setBoard()
之后,我会做类似的事情
for (int i = 0; i < 81; i++)
{
m_square[i]->SetValue(/*square value text*/);
}
这应该可以做到,因为您的方 block 不会改变大小或任何东西。
如果您的控件在更改内容后确实更改了大小,您也必须这样做
vbox->FitInside(this); //since you probably don't want to resize the main window
Layout();
鉴于您的事件处理程序似乎是您的主面板类的成员。
关于c++ - 如何在wxWidgets中刷新,C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27661076/
我刚刚在我的雪豹机器上下载了 wxWidget 源代码。源代码是多平台的,所以它也包含 wxWidget 的 windows 和 GTK 组件。我想编译 wxWidget 源代码,但还没有找到好的指南
我正在使用 C++/wxWidgets 开发一个小型应用程序,其中 GUI 的几个部分需要根据例如更新。收到 UDP 数据报。更具体地说,辅助线程尝试在网络中保留可用“客户端”的列表(可能会出现和消失
我在顶层窗口中有一个 wxPanel 的子类,上面有几层 wxSplitter。当显示窗口时,会发生一些调整大小和布局。当它完成时,我的面板背景在其某些背景上有随机垃圾(黑色或窗口的其他部分)。这似乎
作为 wxWidgets 的新手,我需要一些关于如何让 wxTimer 工作的示例代码。 The reference提供了 3 种使用方法,但不包含其中任何一种的示例代码。最理想的是,我想让方法 2
wxWidgets 库包括一个简单的 HTML 解析器和查看器,我试图用它来显示一些简单的 HTML。我想将某些链接(指向尚不存在的项目的链接)设置为不同的颜色,或者以其他方式表明需要创建它们,但我没
我想将同步事件从工作线程发送到 UI 主线程。我如何在 wxWidgets 中做到这一点? sample 的链接真的很有帮助 最佳答案 您应该使用 队列事件(wxEvent* 事件)用于线程间通信。
任何人都可以推荐 CLion 和 wxWdgets 的教程或入门指南吗?我四处寻找,但找不到任何东西。 最佳答案 好, 你应该在这里下载 WxWidgets http://www.wxwidgets.
希望有人能帮我解决这个问题。我正在使用 Visual Studio 2005 并创建一个静态链接到 wxWidgets 中的静态库。我有: 根据他们的指南静态编译wxWidgets 在我的“附加库目录
我目前正在设计将我现有的 .NET/C#/WinForms 项目迁移到一个平台中立的解决方案,我见过的最有吸引力的替代方案似乎是 wxWidgets,特别是考虑到我对 C++ 和 MFC 的熟悉,这似
几周以来,我一直被 wxWidgets 淹没。但是,我需要一些帮助: 动态链接 Unicode、Release、Non-monolithic 版本的 wxWidgets 3.0.0 时,如何链接以下库
我正在尝试一个新的设置。我使用的是 32 位 Windows 8 Pro 笔记本电脑。我已经下载了 MinGW-builds 的 GCC 4.8.1。我用它来编译 LLVM 和 CLang(3.4+
我正在寻找一个如何使用 WxWidgets 在 Windows 上创建 DLL 库的简单示例。 我需要在 DLL 上使用一些 wxWidgets API,它会从 Delphi 调用。 最佳答案 在您的
打包 Perl wxWidgets 应用程序以分发给未安装 Perl 或 wxWidgets 的 Windows 和 Mac 用户的最佳方法是什么? 有问题的用户不是很懂电脑,所以不能指望他们单独安装
我在处理一些用wxWidgets 2.8 编写的代码,现在需要转移到wxWidgets 2.9。 我这样定义: wxLocale m_locale; 和使用 m_locale.Init(iLocale
我在 linux 或 FreeBSD 上构建 wxWidgets 库时注意到 wxWidgets 需要其他 GUI 库,例如 GTK+、Motif 等,而 GTK+、Motif 或 FLTK 库似乎是
这是一个关于 wxBoxSizer 的问题。我正在实现一个自定义 wxWidget,如可折叠 Pane 。 问题是:我有一个 wxBoxSizer (Sizer1),我添加了另一个 wxBoxSize
我正在尝试编译 wxwidgets。我正在使用 mingw32 进行编译并遵循 zip 文件附带的 install.txt,但是当我编译它时,它给了我这些错误。 如果不存在 gcc_mswd mkdi
我想了解新的主要 wxWidgets 3.0 版本的学习资源。我看到网上有很多旧版本的资源,还有 2005 年的一本书。但我不确定它们是否合适。 Web 教程将是最好的,但欢迎任何内容。 如前所述,我
wxWidgets应用程序在主窗口的状态栏中显示普通菜单项的帮助字符串。不幸的是,对于使用wxWindow::PopupMenu命令调用的菜单,它似乎没有显示它们,我需要这样做。 我尝试将EVT_ME
如何获取模块路径? 我正在编写包含在 DLL 中的扩展,并希望在运行时获取我的库的路径。 更新 当然第一种方法很好用 static wxString GetModulePath() { sta
我是一名优秀的程序员,十分优秀!