Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to disable text entry



  • I have a small issue with my C++ code .

    My base class is QTextEdit - to that class I add QWidget - user access to application.
    Works as desired.

    The "problem" is - the added widget DOES NOT fully covers the underlying "add text feature " to the original display.
    The user can enter any text into the form at any point.

    I would like to disable the "flashing " | mark thus disable the random position text entry marker at the same time.

    I cannot simply remove the "newFile" code - it is used to keep track of the MDI subwindows.

    Addy reasonable suggestion how to do this - disable the text entry - would be appreciated

            //orignal createMdiChild
            MdiChild *child = createMdiChild(); //QTextEdit
            child->setLayout(new QVBoxLayout);
            DeviceDiscoveryDialog *DDD = new DeviceDiscoveryDialog();
            // insert widget
            child->layout()->addWidget(DDD);
           child->newFile();  // create child as file - need file name
            child->show();     // show added widget and original child
    


  • @AnneRanch said in How to disable text entry:

    MdiChild *child = createMdiChild(); //QTextEdit

    https://doc.qt.io/qt-5/qtextedit.html#readOnly-prop

    Is this what you are looking for?

    Edit:
    I read it a few times. Not getting what you need. Would a picture help?



  • @AnneRanch said in How to disable text entry:

    MdiChild *child = createMdiChild(); //QTextEdit

    https://doc.qt.io/qt-5/qtextedit.html#readOnly-prop

    Is this what you are looking for?

    Edit:
    I read it a few times. Not getting what you need. Would a picture help?



  • Here is a screenshot with no text entries , but the flashing "|" symbol - upper left corner - is where text can be added

    f1e93986-d088-4605-ab69-fc062c9a8919-image.png

    Here is after "k" was pressed for a while

    adce19dd-fdaf-40f0-9898-d196986a8d31-image.png

    Obviously goofy thing to let user do.

    Which object can I make "read only"?

    There may be an occasion to have "plain" child submenu , no widget added, so adding text would be OK.

    Hence it should be controlled outside child class.



  • As simple as this
    child->setReadOnly(true);

    Thanks for resolving the problem.


Log in to reply