Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] focus problem on Ubuntu when using QMessageBoxes
QtWS25 Last Chance

[SOLVED] focus problem on Ubuntu when using QMessageBoxes

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 3.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yanbellavance
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alexisdm
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        yanbellavance
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • Y Offline
          Y Offline
          yanbellavance
          wrote on last edited by
          #4

          [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)

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved