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. Check, if a integer in a lineedit is higher than X?
Forum Updated to NodeBB v4.3 + New Features

Check, if a integer in a lineedit is higher than X?

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

    @void MainWindow::on_lineEdit_textChanged(const QString &arg1)
    {
    int sLineEdit = ui->lineEdit->text.toInt;
    if (sLineEdit > 4)
    ui->lineEdit->setText("4");

    }@

    =

    @'((MainWindow*)this)->MainWindow::ui->Ui::MainWindow::<anonymous>.Ui_MainWindow::lineEdit->QLineEdit::text' does not have class type@

    Wtf did I do wrong?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      KA51O
      wrote on last edited by
      #2

      Try "QIntValidator":http://qt-project.org/doc/qt-4.8/qintvalidator.html .

      1 Reply Last reply
      0
      • K Offline
        K Offline
        koahnig
        wrote on last edited by
        #3

        This should work. text and toInt are member functions.

        @
        {
        int sLineEdit = ui->lineEdit->text().toInt();
        if (sLineEdit > 4)
        ui->lineEdit->setText("4");

        }@

        However, as already suggested by use QIntValidator. This is intended for what you are trying to do.

        Vote the answer(s) that helped you to solve your issue(s)

        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