Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.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
C++ 如何在my Qdialogbox';什么是线人?_C++_Qt_Qlineedit_Qmainwindow_Qdialog - Fatal编程技术网

C++ 如何在my Qdialogbox';什么是线人?

C++ 如何在my Qdialogbox';什么是线人?,c++,qt,qlineedit,qmainwindow,qdialog,C++,Qt,Qlineedit,Qmainwindow,Qdialog,在我的主窗口中,我有一个名为employee_list的QlistWidget,该QlistWidget中的项目如下: <FIRM-1> name="Anna Ken" age="25" job="QtMaster" , <FIRM-2> name="Sir Ron" age="50" job="QtSlave" 由于我们无法看到您的GrpComd代码

在我的主窗口中,我有一个名为
employee_list
QlistWidget
,该
QlistWidget
中的项目如下:

<FIRM-1> name="Anna Ken" age="25" job="QtMaster" ,
<FIRM-2> name="Sir Ron" age="50" job="QtSlave"

由于我们无法看到您的
GrpComd
代码,因此无法知道您是否初始化了该指针。或者即使它是
公共
成员


无论如何,您应该在调用dialog
exec()
之前设置文本。而
QLineEdit
的方法是
setText
而不是“setText”--注意大写字母“T”

您必须填写并显示,即
setText()
,然后
show()
exec()


@eyllanesc,谢谢你的编辑,我的声誉不到10,我无法正常发布图片。谢谢,这帮助了我的问题。
void MainWindow::on_employee_list_itemDoubleClicked(QListWidgetItem* item)
{
    QString test = item->text();             // getting the item text
    std::string test_s = test.toStdString();  //converting it to string from Qstring
    string name_part = "";                     //creating a variable in which name will be stored

        int name_pos = test_s.find("name=\"");
        for (int i = name_pos + 6; i < test_s.length();i++)
        {
            if (test_s[i] != '\"')
                name_part += test_s[i];
            else
                break;                         //extracting name in the item's text, after this the name_part variable value is Sir ron.  // similar code for extarcting age and job.
            
    if (test_s.find("<FIRM-1>") != std::string::npos)   //if item contains text <FIRM-1> then show this dialogue
    {
        GrpComd grpComd;   //creating instance of dialog
        grpComd.exec();    //showing it 
              
       grpComd.name_lineedit->settext(name_part);  // i tried this to populate name in name_linedit but getting error , access violation reading location
    }
}
if (test_s.find("<FIRM-1>") != std::string::npos)  
{
    GrpComd grpComd;
    grpComd.setName(clickedName); 
    grpComd.setJob(clickedJob); 
    grpComd.setAge(clickedAge); 
    grpComd.exec();  
}
GrpComd::GrpComd(const QString& name,const QString& job, uint age);