Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/128.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
wxWidgets附加到wxChoice列表的站点 我为一个大学项目建立了一个基本的GUI,我使用WxWIDGET和CODBROCK,因为C++是我的舒适编程语言。但是,我想修改wxChoice上的选项,因为这些选项并不总是相同的,这意味着如果我在选项列表中添加了一些内容,然后我想将列表更新为一个完全不同的列表,首先我必须从选项列表中删除旧项,然后再添加新项,但是我找不到怎么做。这是我的密码: //Event void TestFrame::OnChoice1Select(wxCommandEvent& event) { fstream in; string str,str2; int i; //File where I store my list of lists in.open("Recursos/Carreras-LC.txt",ios::in); //Go to an specific line of the file where the list for the current choice is in=gotoLine(in,Choice1->GetSelection()+1); //Gets the line with the list getline(in,str,'\n'); in.close(); //Here is where I'll put the code to remove the current list of choices //My code to append the items from the list i got before i=0; while(str[i]!='\0'){ if(str[i]==','){ Choice2->Append(_(str2)); i++; str2=""; }else{ str2+=str[i]; i++; } } }_C++_Append_Codeblocks_Wxwidgets - Fatal编程技术网

wxWidgets附加到wxChoice列表的站点 我为一个大学项目建立了一个基本的GUI,我使用WxWIDGET和CODBROCK,因为C++是我的舒适编程语言。但是,我想修改wxChoice上的选项,因为这些选项并不总是相同的,这意味着如果我在选项列表中添加了一些内容,然后我想将列表更新为一个完全不同的列表,首先我必须从选项列表中删除旧项,然后再添加新项,但是我找不到怎么做。这是我的密码: //Event void TestFrame::OnChoice1Select(wxCommandEvent& event) { fstream in; string str,str2; int i; //File where I store my list of lists in.open("Recursos/Carreras-LC.txt",ios::in); //Go to an specific line of the file where the list for the current choice is in=gotoLine(in,Choice1->GetSelection()+1); //Gets the line with the list getline(in,str,'\n'); in.close(); //Here is where I'll put the code to remove the current list of choices //My code to append the items from the list i got before i=0; while(str[i]!='\0'){ if(str[i]==','){ Choice2->Append(_(str2)); i++; str2=""; }else{ str2+=str[i]; i++; } } }

wxWidgets附加到wxChoice列表的站点 我为一个大学项目建立了一个基本的GUI,我使用WxWIDGET和CODBROCK,因为C++是我的舒适编程语言。但是,我想修改wxChoice上的选项,因为这些选项并不总是相同的,这意味着如果我在选项列表中添加了一些内容,然后我想将列表更新为一个完全不同的列表,首先我必须从选项列表中删除旧项,然后再添加新项,但是我找不到怎么做。这是我的密码: //Event void TestFrame::OnChoice1Select(wxCommandEvent& event) { fstream in; string str,str2; int i; //File where I store my list of lists in.open("Recursos/Carreras-LC.txt",ios::in); //Go to an specific line of the file where the list for the current choice is in=gotoLine(in,Choice1->GetSelection()+1); //Gets the line with the list getline(in,str,'\n'); in.close(); //Here is where I'll put the code to remove the current list of choices //My code to append the items from the list i got before i=0; while(str[i]!='\0'){ if(str[i]==','){ Choice2->Append(_(str2)); i++; str2=""; }else{ str2+=str[i]; i++; } } },c++,append,codeblocks,wxwidgets,C++,Append,Codeblocks,Wxwidgets,另外,如果有更好的方法来实现这种动态GUI,请告诉我。提前谢谢 我必须从选项列表中删除旧项,然后附加新项,但我找不到如何做 可以使用wxChoice::Clear()方法从选择控件中删除所有项,也可以使用wxChoice::Delete(unsigned int n)方法从控件中删除特定项 它们列在“从wxItemContainer继承的公共成员函数”部分的下面 另外,如果有更好的方法来实现这种动态GUI,请告诉我。提前谢谢 一个选项是使用,以便在主机架空闲时更新选项。如果你要走那条路,我会的

另外,如果有更好的方法来实现这种动态GUI,请告诉我。提前谢谢

我必须从选项列表中删除旧项,然后附加新项,但我找不到如何做

可以使用wxChoice::Clear()方法从选择控件中删除所有项,也可以使用wxChoice::Delete(unsigned int n)方法从控件中删除特定项

它们列在“从wxItemContainer继承的公共成员函数”部分的下面

另外,如果有更好的方法来实现这种动态GUI,请告诉我。提前谢谢

一个选项是使用,以便在主机架空闲时更新选项。如果你要走那条路,我会的

  • 将名为
    m_choiceNeedsUpdate
    或类似名称的bool成员和事件处理程序
    void onUpdate ui(wxUpdate UIEvent&event)
    (或任何您想要调用的)添加到应用程序窗体的类中
  • 使用类似于
    this->Bind(wxEVT_UPDATE_UI,&MyFrame::OnUpdateUI,this)的调用绑定框架构造函数中的事件处理程序
  • 当您执行需要更新选项的操作时,您可以安排使用以下调用更新选项:

    m_choiceNeedsUpdate=true;
    this->UpdateWindowUI();
    
  • 更新choice控件的事件处理程序的主体可能如下所示

    void MyFrame::OnUpdateUI(wxUpdateUIEvent& event)
    {
        if (m_choiceNeedsUpdate)
        {
            //Update the choice control here (probably using the Clear/Delete methods)
            m_choiceNeedsUpdate=false;
        }
    }
    
  • 这样做的好处是,所有关于更新UI的逻辑都可以放在一个方法/事件处理程序中。如果您有多个可能需要动态更新的控件,这一点尤其好

    缺点是,当您的框架运行时,会有很多对该事件处理程序的调用,这可能会影响性能。这就是为什么我在上面的示例中使用m_choiceNeedsUpdate bool变量来更改choice控件的逻辑

    我必须从选项列表中删除旧项,然后附加新项,但我找不到如何做

    可以使用wxChoice::Clear()方法从选择控件中删除所有项,也可以使用wxChoice::Delete(unsigned int n)方法从控件中删除特定项

    它们列在“从wxItemContainer继承的公共成员函数”部分的下面

    另外,如果有更好的方法来实现这种动态GUI,请告诉我。提前谢谢

    一个选项是使用,以便在主机架空闲时更新选项。如果你要走那条路,我会的

  • 将名为
    m_choiceNeedsUpdate
    或类似名称的bool成员和事件处理程序
    void onUpdate ui(wxUpdate UIEvent&event)
    (或任何您想要调用的)添加到应用程序窗体的类中
  • 使用类似于
    this->Bind(wxEVT_UPDATE_UI,&MyFrame::OnUpdateUI,this)的调用绑定框架构造函数中的事件处理程序
  • 当您执行需要更新选项的操作时,您可以安排使用以下调用更新选项:

    m_choiceNeedsUpdate=true;
    this->UpdateWindowUI();
    
  • 更新choice控件的事件处理程序的主体可能如下所示

    void MyFrame::OnUpdateUI(wxUpdateUIEvent& event)
    {
        if (m_choiceNeedsUpdate)
        {
            //Update the choice control here (probably using the Clear/Delete methods)
            m_choiceNeedsUpdate=false;
        }
    }
    
  • 这样做的好处是,所有关于更新UI的逻辑都可以放在一个方法/事件处理程序中。如果您有多个可能需要动态更新的控件,这一点尤其好


    缺点是,当您的框架运行时,会有很多对该事件处理程序的调用,这可能会影响性能。这就是为什么我在上面的示例中使用m_choiceNeedsUpdate bool变量来保护更改choice控件的逻辑。

    wxEVT\u UPDATE\u UI
    不是这样使用的,它应该直接更新控件,而不是设置标志。如果您这样做,那么直接使用
    wxEVT\u IDLE
    就不会那么混乱了。
    wxEVT\u UPDATE\u UI
    不是这样使用的,它应该直接更新控件,而不是设置标志。如果您只是这样做,那么直接使用
    wxEVT_IDLE
    就不会那么混乱了。