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. Plain Edit text "" return int from Qstring"

Plain Edit text "" return int from Qstring"

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 766 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.
  • A Offline
    A Offline
    Amine Djeddi
    wrote on last edited by VRonin
    #1

    Hi Qties !! im trying to change the Variable "a" from PlainTextEdit !! but it's doent work
    any suggestions please ?

    if (ui.bitwiseAND->isChecked())
    
    		{
    			int a ;
    			QString g = ui.plainTextEdit_2->toPlainText();
    			a = g.toInt();
    
    			medianBlur(HidedSrc, Mblurred, a);
    			namedWindow("Mblurred", WINDOW_NORMAL); 
    		}
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What does ui.plainTextEdit_2 contain ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        What does ui.plainTextEdit_2 contain ?

        A Offline
        A Offline
        Amine Djeddi
        wrote on last edited by
        #3

        @SGaist

        it's empty !!

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          And you are expecting toInt to return what if your string is empty ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          A 1 Reply Last reply
          2
          • SGaistS SGaist

            And you are expecting toInt to return what if your string is empty ?

            A Offline
            A Offline
            Amine Djeddi
            wrote on last edited by
            #5

            @SGaist
            i set a = 3 , it's works ... you opened my eyes thank you .... i'm so newby

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              toInt has a boolean parameter that you can use to validate that the conversion was successful.

              On a related note, if you want to have an numerical input there, why not use something more appropriate like a QSpinBox ? That way you don't even have to deal with conversion.

              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
              2

              • Login

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