QTextEdit - not accepting keyboard inputs
-
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)
-
C Christian Ehrlicher moved this topic from Qt Creator and other tools on
-
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.