[SOLVED] focus problem on Ubuntu when using QMessageBoxes



  • It looks like there is a bug when running Qt apps on Ubuntu, I don't know if the bug is on the Qt side or the Ubuntu but I have a feeling that this was not present in past versions of Ubuntu and I do not see this happen on red hat. Im hoping you guys can validate if I am doing something wrong first.

    Here is the situation: I push a button on my ui which is connected to a slot. Inside that slot I open a QMessageBox. If i click on the Ok button everything is fine but if i simply click enter without focusing on the message box first the I cannot edit QLineEdits or QSpinBoxes of that ui until i focus another window then come back to it. Here is the slot's code in my QMainWindow:

    @ void on_pushButton_clicked(){

        QMessageBox clrMsg;
        clrMsg.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
        clrMsg.setWindowTitle("IRIG-B");
        clrMsg.setText("Are you sure you want to clear the IRIG-B faults?");
        int res=clrMsg.exec();
        if(res==QMessageBox::Yes){
            //...do my stuff
        }
    }
    

    @

    P.S. I am currently using ubuntu 10.04 LTS. This is easilly reproducable, just add this slot to the MainWindow of a new project and add a pushbutton, qlineedit and qspinbox to the mainwindow form. Start the app, click the pushbutton, click enter , try to edit spinboxes or lineedits->res: can't edit them with keyboard unless you alt+tab and back first



  • Does it do the same thing if you add the main window (this) as parent of the message box ?



  • that's a good point. let me try that.



  • [quote author="alexisdm" date="1312852866"]Does it do the same thing if you add the main window (this) as parent of the message box ?
    [/quote]

    It worked thanks! I am curious to know why this was not necessary on red hat and also on another ubuntu (10.04 LTS 32 bit vmware using qt4.7 instead of qt4.6)


Log in to reply
 

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