Not responding dialog



  • hi all
    i'm writing a program that there are two dialogs in it.by pushing a button in first dialog ,data that is written in a line edit should be recieved and second dialog should be open.the problem is that when i run this program,sometimes it works properly.but sometimes it becomes not responding!I check the code in( pushing button function),but i didn't find anything wrong.what's the problem ?what should i do?
    thanks.



  • Hard to tell without seeing the code.



  • this is the code about pushing button function:
    @void SearchContent::on_cmdOk_clicked()
    {
    Content content;
    Contents contents;
    TagRelations tagRelations;
    Tags tags;
    vector<Tag> tag;
    QString title=ui->Title->text();
    std::string t=title.toLocal8Bit().constData();
    content =contents.getByTitle(t);
    if(contents.Found==true)
    {
    AddContent *myAddContent=new AddContent;
    myAddContent->show();
    this->close();
    }
    else
    {
    QMessageBox::information(this,"Error",QString("content with this title not found."));
    }

    }@

    Content,Contents,Tags and TagRealtions are classes that i define them.and Found is a boolean memeber from Contents class that is false by default.but when (getByTitle() ) function from this classis is called ,
    if this function can find the content ,Found will become true.



  • and this is the content class and boolean member Found:
    @class Contents : public BaseEntity
    {

    public:
    bool Found;
    Contents()
    {
    file="content.dat";
    fp=0;
    openFile(file);
    this->Found=false;

    }

    Content getByTitle(string Title)
    {
    this->Found=false;
    int MaxID;
    fseek(fp,0,SEEK_SET);
    myfread(MaxID);
    while (!feof(fp))
    {
    int recordSize, isDeleted;
    myfread(recordSize);
    if (feof(fp)) break;
    myfread(isDeleted);
    if (isDeleted)
    {
    char buffer=new char[recordSize];
    fread(buffer,recordSize-metaSize
    1,1,fp);
    delete []buffer;
    }
    else
    {
    Content c;
    myfread(c.ID);
    myfread(c.OwnerID);
    myfread(c.Timestamp);
    readWithSize(c.Title);
    readWithSize(c.Body);
    if (c.Title==Title)
    {
    this->Found=true;
    return c;
    }
    }
    }
    return Content();
    }@

    i think the problem is about Found member .because when i remove( if & else) part which is realted to Found memeber,program runs properly.but i don't know what's the problem?



  • nobody knows the answer?



  • Your style of coding is really kind of C programing, and the dialog unresponding should have nothing relationship with Qt UI, QDialog, related to your while loop and logic.



  • you mean the problem is in while loop?



  • [quote author="r@h@" date="1310724528"]
    @
    AddContent *myAddContent=new AddContent;
    myAddContent->show();
    this->close();
    @
    [/quote]

    You have some problems here. Where you delete the memory allocated for myAddContent ? And ... are you sure you want to close first dialog ? If you just want to hide call QWidget::hide() or QDialog::setVisible(false)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.