Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved
    1. Home
    2. Tags
    3. qlineedit

    Log in to post
    • All categories
    • B

      Solved TextEdited set QTableView cell value
      General and Desktop • c++ qlineedit qtableview • • BushyAxis793

      3
      0
      Votes
      3
      Posts
      81
      Views

      B

      @SGaist This is the solution! Thank you very much. Below is my new setData() and TextEdited()

      setData()

      bool SummaryModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (index.isValid() && role == Qt::EditRole) { SetSummaryQuantity(value.toInt()); emit dataChanged(index,index); return true; } else { return false; } return false; }

      TextEdited()

      void QueriesCreator::on_quantityGeneralInformationLineEdit_textEdited(const QString &arg1) { calculations.SetMaterialQuantity(ui->quantityGeneralInformationLineEdit->text().toInt()); CalculateMaterialCostInZloty(); summaryModel->setData(ui->summaryDefaultTableView->model()->index(6,0),ui->quantityGeneralInformationLineEdit->text().toInt(),Qt::EditRole); }

      and of course the data()

      QVariant SummaryModel::data(const QModelIndex &index, int role) const { if (role == Qt::DisplayRole) { //Quantity if (index.row() == 0 && index.column() == 0) return QString("50"); if (index.row() == 2 && index.column() == 0) return QString("100"); if (index.row() == 4 && index.column() == 0) return QString("1000"); if (index.row() == 6 && index.column() == 0) return GetSummaryQuantity(); //Currency- byc w moze w przyszlosci zmienic na inne if (index.row() == 0 && index.column() == 1) return QString("PLN"); if (index.row() == 1 && index.column() == 1) return QString("EUR"); if (index.row() == 2 && index.column() == 1) return QString("PLN"); if (index.row() == 3 && index.column() == 1) return QString("EUR"); if (index.row() == 4 && index.column() == 1) return QString("PLN"); if (index.row() == 5 && index.column() == 1) return QString("EUR"); if (index.row() == 6 && index.column() == 1) return QString("PLN"); if (index.row() == 7 && index.column() == 1) return QString("EUR"); //Price Placeholders //Material if (index.row() == 0 && index.column() == 2) return QString("0,00"); if (index.row() == 1 && index.column() == 2) return QString("0,00"); if (index.row() == 2 && index.column() == 2) return QString("0,00"); if (index.row() == 3 && index.column() == 2) return QString("0,00"); if (index.row() == 4 && index.column() == 2) return QString("0,00"); if (index.row() == 5 && index.column() == 2) return QString("0,00"); if (index.row() == 6 && index.column() == 2) return QString("0,00"); if (index.row() == 7 && index.column() == 2) return QString("0,00"); //Machining if (index.row() == 0 && index.column() == 3) return QString("0,00"); if (index.row() == 1 && index.column() == 3) return QString("0,00"); if (index.row() == 2 && index.column() == 3) return QString("0,00"); if (index.row() == 3 && index.column() == 3) return QString("0,00"); if (index.row() == 4 && index.column() == 3) return QString("0,00"); if (index.row() == 5 && index.column() == 3) return QString("0,00"); if (index.row() == 6 && index.column() == 3) return QString("0,00"); if (index.row() == 7 && index.column() == 3) return QString("0,00"); //Diference if (index.row() == 0 && index.column() == 4) return QString("0,00"); if (index.row() == 1 && index.column() == 4) return QString("0,00"); if (index.row() == 2 && index.column() == 4) return QString("0,00"); if (index.row() == 3 && index.column() == 4) return QString("0,00"); if (index.row() == 4 && index.column() == 4) return QString("0,00"); if (index.row() == 5 && index.column() == 4) return QString("0,00"); if (index.row() == 6 && index.column() == 4) return QString("0,00"); if (index.row() == 7 && index.column() == 4) return QString("0,00"); } if(role==Qt::TextAlignmentRole) { return Qt::AlignCenter; } return QVariant(); }

      Now It works as I expect. Thanks and Have a good day!

    • CJha

      Solved Line edit for QListWidgetItem?
      General and Desktop • qlistwidgetitem qlineedit • • CJha

      6
      0
      Votes
      6
      Posts
      439
      Views

      Pl45m4

      @CJha

      https://stackoverflow.com/questions/26614678/validating-user-input-in-a-qtableview
      (will work for every model/view, I think)

      Here you go :)

    • HowardHarkness

      Solved How do I fix strange cursor behavior in QLineEdit using inputMask containing spaces?
      General and Desktop • qlineedit inputmask • • HowardHarkness

      2
      0
      Votes
      2
      Posts
      296
      Views

      Pl45m4

      @HowardHarkness

      Hi there was a similar topic / question few years ago.
      @SGaist explained why there is one additional space after every mask -> to allow text selection by keyboard.
      Of course Ctrl + A kinda "hacks" it (to select all, at least) and if you dont need it, you could implement a workaround, but unfortunately there is no "Qt-way" to switch it off.

      https://forum.qt.io/topic/60633/qlineedit-using-input-mask-with-blank-space-replacement-cursor-select-replacement-char
    • B

      Solved Subclassed QLineEdit styleSheet update triggers stack overflow
      General and Desktop • qlineedit stack-overflow • • BartM

      6
      0
      Votes
      6
      Posts
      129
      Views

      JonB

      @BartM
      I am glad you changed approach.

      This new list of pointers was then forwarded to another thread running in the background that iterates through the list, and emits a signal to setStyleSheet that is then received in the main thread.

      I still don't know why you need any thread at all, seems more complicated than it needs to be. But if you're happy that's fine :)

    • A

      Unsolved How do you properly increase QLineEdit increase icon size/
      General and Desktop • qlineedit icon size pixelated • • arjun98

      4
      0
      Votes
      4
      Posts
      945
      Views

      nagesh

      @arjun98 said in How do you properly increase QLineEdit increase icon size/:

      ui->searchbar->setClearButtonEnabled(true);
      ui->searchbar->QLineEdit::addAction(QIcon(":/img/icons/icon_search.png"), QLineEdit::LeadingPosition);

      I have tried loading icon to line edit using above code, it's clearly visibile. and image is not blurred.
      try to experiment loading the icon to QLineEdit without any stylesheet being set to it.

    • H

      Unsolved QLineEdit is overwriting the first input character (bug?)
      Mobile and Embedded • android qlineedit widget bug • • Hector_WPG

      3
      0
      Votes
      3
      Posts
      365
      Views

      aha_1980

      @jsulm That is correct, but I'd first try with the latest Qt 5 version 5.15.2

      Regards

    • D

      Unsolved Can't use on-screen keyboard on tvOS
      Mobile and Embedded • tvos appletv c++ qlineedit keyboard • • dbaldassi

      1
      0
      Votes
      1
      Posts
      176
      Views

      No one has replied

    • L

      Unsolved How to populate values in my Qdialogbox's linedits?
      General and Desktop • c++ qt 5.4 qdialog qlineedit qmainwindow • • learnist

      6
      0
      Votes
      6
      Posts
      306
      Views

      SGaist

      Hi,

      exec is a blocking call so basically you modify your dialog content after you dismiss it.

    • A

      Solved QLineEdit Selection changed()
      General and Desktop • qt for windows qlineedit qmouseevent • • Andrex_Qt

      3
      0
      Votes
      3
      Posts
      637
      Views

      A

      Thanks for the insight, still my issue was that you have to double click (mouse or touch) the LineEdit to get its selection. Now in place of LineEdit i have used TextEdit, it works on single click. Thanks again for the reply.

    • nicmorais

      Solved Pass value to Dialog/set Values
      General and Desktop • qdialog pass value qlineedit • • nicmorais

      7
      0
      Votes
      7
      Posts
      1137
      Views

      nicmorais

      Wow! Thank you @JonB, this solved my issue. One more solved topic to the forum.
      Have a nice a nice day!

    • D

      Solved Problem overriding mousePressEvent
      General and Desktop • c++ qt 5.9.5 qlineedit • • Daniel_Contro

      6
      1
      Votes
      6
      Posts
      1126
      Views

      mrjj

      @Daniel_Contro
      hi
      Good to hear.
      best to set this as solved and make a new one as then its easier for others to search :)

    • oblivioncth

      Solved Potential Bug (Qt 5.15): QLineEdit emits "editingFinished()" signal twice when the text is changed and enter is pressed
      General and Desktop • qlineedit signal emit signal • • oblivioncth

      13
      0
      Votes
      13
      Posts
      2400
      Views

      oblivioncth

      My behavior correction patch for this one has also gone through to be available in 6.0/the current dev build

      https://codereview.qt-project.org/c/qt/qtbase/+/312083

      Cheers.

    • M

      Unsolved Styling of QLineEdit/QListView child of QCombobox on hover
      General and Desktop • qss qcombobox qlineedit • • mikael.larsson

      3
      0
      Votes
      3
      Posts
      571
      Views

      mrjj

      @mikael-larsson
      Hi
      You could try an event filter on the Combobox and call the code for hover effect but
      if your effect is purely stylesheet based then i think you then must send it fake hover event to trigger it or something like that.

      You might also be able to subclass the combo and rig the paintEvent with
      if (someflag)
      option.state |= QStyle::State_MouseOver;

      to trigger hover on command from the event filter/ or combo hover or how you plan to trigger it.

    • Lemat

      Solved how to capture a mouse leave event only on a specific QWidget ( a QlineEdit ) ?
      General and Desktop • qmouseevent qlineedit • • Lemat

      6
      0
      Votes
      6
      Posts
      910
      Views

      Lemat

      @Alain38-0 okay, i will use it for another project. thanks.

    • ?

      Solved Add TreeWidget item from another dialog
      General and Desktop • qtreewidget qlineedit qmainwindow qdialog • • A Former User

      3
      0
      Votes
      3
      Posts
      560
      Views

      ?

      Thanks, mrjj!
      That's it!

      Merry christmas

    • J

      Solved QLineEdit: clear mask when not editing
      General and Desktop • qlineedit mask • • Justin Iurman

      5
      0
      Votes
      5
      Posts
      966
      Views

      J

      @mrjj
      Thanks for the welcoming :-)

      Indeed, the QStyledItemDelegate works fine, but only when I use a QTableWidget. So a first solution was to create a QTableWidget with 1 row and 1 column, and insert my delegate inside. The problem with this technique is that it's hard to perfectly mimic a QLineEdit (behavior, style, etc). For instance, with a QTableWidget, there is no simple click on items to enter in edit mode (this is a double click, at least), as far as I know. It's still possible to redefine the behavior, I guess, but it's not worth it. I don't like the whole thing.

      That's why I came up with another idea. This time, I keep my QLineEdit as is, and I add/remove the input mask when having/losing focus. Thanks to that, I'm now able to see the "true" text (without mask format) when I'm not editing it (QLineEdit does not have the focus), while I can see the text (with mask format) when I'm editing it (has focus). I know it's not totally elegant, but I don't think there is an elegant solution at all for this "problem".

      For those interested, a quick example on how to achieve this:
      (1) install an event filter (installEventFilter()) on the QLineEdit
      (2) filter on focus in/out
      (2.1) focus in: add the mask (setInputMask())
      (2.1) focus out: remove the mask and set the text to the value before the mask was removed (because removing the mask erases the text inside the QLineEdit)

    • L

      Solved Signal and slot wrong value being sent
      General and Desktop • qtcreator signal & slot button qlineedit • • Lasith

      5
      0
      Votes
      5
      Posts
      1668
      Views

      mrjj

      Hi
      Yes calling the function directly is actually a better solution in this case.
      Its worth mentioning that the so called slots are 100% normal c++ member functions
      and can be called without any Qt involvement/use of.

      void MainWindow::on_pushButton_clicked() { int value=ui->lineEdit->text().toInt(); // get value Dialog dialog1; dialog1.sendIntData(value); dialog1.exec(); }
    • Sh1gs

      Solved Multiple LineEdits focus issues
      General and Desktop • qlineedit focus issue focus ip editor customplugin • • Sh1gs

      7
      0
      Votes
      7
      Posts
      2666
      Views

      E

      Thanks for posting your solution.

      Happy coding.