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. QTextEdit - not accepting keyboard inputs

QTextEdit - not accepting keyboard inputs

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.9k Views 1 Watching
  • 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.
  • J Offline
    J Offline
    jakubd
    wrote on last edited by
    #1

    Hello,
    I am having trouble with a qtextedit. When I create a popup windown, I add a few of them. Unfortunately non of them accept any input from the keyboard. Anyone have any ideas? I commented out the things I tried to make it work, as a sort of trail and error method since I couldnt think of anything else to do.

    QWidget* popUpNewDate;
    QPlainTextEdit* cityInputForAddingDate;
    QDateEdit* dateChoiceForAddingDate;
    QComboBox* venueChoiceForAddingDate;
    QComboBox* titleChoiceForAddingDate;
    void eventsOverview::on_addDateButton_clicked()
    {
    
        popUpNewDate = new QWidget(this, Qt::Popup);
        popUpNewDate->setWindowModality(Qt::WindowModal);
        QRect rect = QStyle::alignedRect(layoutDirection(), Qt::AlignBottom, QSize(width()/2, height()/2), geometry());
        popUpNewDate->setGeometry(rect);
    
        QVBoxLayout* layoutVer1 = new QVBoxLayout(popUpNewDate);
        QHBoxLayout* layoutHor1 = new QHBoxLayout();
        QHBoxLayout* layoutHor2 = new QHBoxLayout();
        QHBoxLayout* layoutHor3 = new QHBoxLayout();
        QHBoxLayout* layoutHor4 = new QHBoxLayout();
        QHBoxLayout* layoutHor5 = new QHBoxLayout();
    
        QLabel* cityLabel = new QLabel("City name: ");
        cityInputForAddingDate = new QPlainTextEdit("-- CHOOSE CITY --");
        cityInputForAddingDate->setMaximumHeight(30);
        cityInputForAddingDate->grabKeyboard();
        cityInputForAddingDate->ensureCursorVisible();
        cityInputForAddingDate->setAcceptDrops(true);
       // cityInputForAddingDate->setAcceptRichText(true);
        //cityInputForAddingDate->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
        //cityInputForAddingDate->setFocus();
        //cityInputForAddingDate->setTabChangesFocus(true);
        //cityInputForAddingDate->setReadOnly(false);
    
        QLabel* dateLabel = new QLabel("Date name: ");
        dateChoiceForAddingDate = new QDateEdit();
        dateChoiceForAddingDate->setMinimumWidth(400);
        QDate* startingDate = new QDate(2022, 9, 1);
        dateChoiceForAddingDate->setDate(*startingDate);
        dateChoiceForAddingDate->setDisplayFormat(QString("dd.mm.yyyy"));
    
        QPushButton* preloadVenuesButton = new QPushButton("PRELOAD VENUES");
        preloadVenuesButton->setMaximumWidth(150);
        venueChoiceForAddingDate = new QComboBox();
        venueChoiceForAddingDate->setMaximumWidth(250);
        venueChoiceForAddingDate->addItem(QString("-- PRELOAD VENUES --"));
    
        QLabel* titleChoiceLabel = new QLabel("Title: ");
        titleChoiceForAddingDate = new QComboBox();
        titleChoiceForAddingDate->addItem(QString("-- CHOOSE TITLE --"));
     
        QPushButton* saveButton = new QPushButton("SAVE");
    
        layoutHor1->addWidget(cityLabel);
        layoutHor1->addWidget(cityInputForAddingDate);
    
        layoutHor2->addWidget(dateLabel);
        layoutHor2->addWidget(dateChoiceForAddingDate);
    
        layoutHor3->addWidget(preloadVenuesButton);
        layoutHor3->addWidget(venueChoiceForAddingDate);
    
        layoutHor4->addWidget(titleChoiceLabel);
        layoutHor4->addWidget(titleChoiceForAddingDate);
    
        layoutHor5->addWidget(saveButton);
    
        layoutVer1->addLayout(layoutHor1, 0);
        layoutVer1->addLayout(layoutHor2, 0);
        layoutVer1->addLayout(layoutHor3, 0);
        layoutVer1->addLayout(layoutHor4, 0);
        layoutVer1->addLayout(layoutHor5, 0);
    
        popUpNewDate->show();
    
        connect(preloadVenuesButton, &QPushButton::clicked, this, &eventsOverview::preloadingVenues);
        connect(saveButton,&QPushButton::clicked,this, &eventsOverview::addingDate);
    
    }
    
    

    c++ (obv)

    1 Reply Last reply
    0
    • Christian EhrlicherC Christian Ehrlicher moved this topic from Qt Creator and other tools on
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You should provide minimal compilable example that shows that behaviour.
      Also, which version of Qt are you using ?
      On which OS ?

      Finally, in this code you are leaking QDate objects.
      The same goes of the widgets you create in that function. Each time you call it a new set of them will be created without deleting the old ones.

      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
      1

      • Login

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