no reaction at the first touch on the new form from doubleclick on a listview



  • I have a ListVew and button on my widget.
    there are two different reaction:
    condition 1. (OK)
    When I press the button , the new form(MyDesign) will be generated.
    And I can get reaction from the first pressing button on the generated form(MyDesign) .
    condition 2.(NOT OK)
    When I doubleclick the item on a listview , the new form(MyDesign) will be generated.
    But there are no reaction from the first pressing button on the new form(MyDesign).

    (the slot of btnOK and lvwFile are both on_btnOK_clicked())
    Why?
    How to correct it?

        btnOK=new MainButton(this);
        btnOK->setFocusPolicy(Qt::NoFocus);
        connect(btnOK, SIGNAL(onClicked()), this, SLOT(on_btnOK_clicked()));
        ui->lvwFile->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
        ui->lvwFile->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
        ui->lvwFile->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
        ui->lvwFile->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
        QScroller::grabGesture(ui->lvwFile,QScroller::LeftMouseButtonGesture);
        connect(ui->lvwFile, SIGNAL(clicked(QModelIndex)), this, SLOT(lvwFile_Clicked()));
        connect(ui->lvwFile, SIGNAL(onPressed()), this, SLOT(Delete_Clicked()));
        connect(ui->lvwFile, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(on_btnOK_clicked()));
    
    
    void diaOpenFileByListView::on_btnOK_clicked()
    {
        lvwFile_Clicked();
        strPath=ui->lblPath->text();
        if(strPath.isNull()==false && strPath!=""){
            MyDesign *formDesign=new MyDesign(this);
            formDesign->setGeometry(0,0,this->width(),this->height());
            formDesign->filePath=strPath;
            formDesign->exec();
            //this->close();
            //delete ui;
            BindLV();
        }
    }
    


  • what different between clicked and doubleClicked?

    In doubleClicked case,
    I can't press the button before touching the screen on my new widget.
    connect(ui->lvwFile, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(on_btnOK_clicked()));

    In clicked case,
    I can press the button before touching the screen on my new widget.
    connect(ui->lvwFile, SIGNAL(clicked(QModelIndex)), this, SLOT(on_btnOK_clicked()));

    But, I want to use doubleClicked....


Log in to reply
 

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