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. QLineEdit no longer accepts input after dis- and reenable QMainWindow on Mac/4.8.5
QtWS25 Last Chance

QLineEdit no longer accepts input after dis- and reenable QMainWindow on Mac/4.8.5

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.7k 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.
  • M Offline
    M Offline
    Macintron
    wrote on last edited by
    #1

    Steps to reproduce:

    QLineEdit widget in QMainWindow

    window()->setEnabled(false); // disable whole window/menu for device communication, no abort

    window()->setEnabled(true); // enable it again

    QLineEdit no longer reacts to keyboard input

    I can reproduce this on Mac 10.8.5 with Qt 4.8.5. Works on Win/4.8.5

    Is this a bug or do I something wrong?
    What else than disabling the mainwindow would you suggest to prevent user input while communicating to a device? The user should not be able to do anything (quit, click widgets, select menu items,...). Switching apps, moving windows is ok.

    MainWindow.cpp
    @#include "MainWindow.hpp"

    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    {
    mEdit = new QLineEdit("after clicking the button, you no longer can edit this text", this);
    mButton = new QPushButton("Disable window for 1 second", this);
    mTimer = new QTimer(this);

    QWidget *centralwidget = new QWidget(this);
    QVBoxLayout *layout = new QVBoxLayout(centralwidget);
    layout->addWidget(mEdit);
    layout->addWidget(mButton);

    setCentralWidget(centralwidget);
    resize(500, 70);

    connect(mButton, SIGNAL(clicked()), this, SLOT(buttonClicked()));
    connect(mTimer, SIGNAL(timeout()), this, SLOT(reenable()));
    }

    MainWindow::~MainWindow()
    {
    }

    void MainWindow::buttonClicked()
    {
    // disable whole window/menu for device communication, no abort
    window()->setEnabled(false);
    mTimer->start(1000); // reenable after a second
    }

    void MainWindow::reenable()
    {
    window()->setEnabled(true);
    }@

    MainWindow.hpp
    @#ifndef MAINWINDOW_HPP
    #define MAINWINDOW_HPP

    #include <QtGui>

    class MainWindow : public QMainWindow
    {
    Q_OBJECT
    QLineEdit *mEdit;
    QPushButton *mButton;
    QTimer *mTimer;

    public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();

    public Q_SLOTS:
    void buttonClicked();
    void reenable();
    };

    #endif // MAINWINDOW_HPP@

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You might be experiencing the same problem described "here":http://qt-project.org/forums/viewthread/34090/

      You can try the patch attached to the bug report

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Macintron
        wrote on last edited by
        #3

        Thank you. This one line patch solved the issue.

        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