Qtablewidgetitem characters that are not numbers can also be entered when editing by default. How do I set a number that is not a numeric input? Qtablewidgetitem Default
Qtablewidgetitem characters that are not numbers can also be entered when editing by default. How do I set a number that is not a numeric input?
Qtablewidgetitem characters that are not numbers can also be entered when editing by default. How do I set a number that is not a numeric input?
[Workaround]
Qregexp ipregexp = Qregexp ("(2[0-4]\\d|25[0-5]|[ 01]?\\d\\d?) \\.) {4} ");
Qregexpvalidator *ipregexpvalidator = new Qregexpvalidator (ipregexp, this);
Iplineedit->setvalidator (Ipregexpvalidator);
Iplineedit->setinputmask ("000.000.000.000;");
This is the authentication method for IP you just change it. I never tried.
[Workaround]
LZ according to your requirements, I disguised the realization of the next, the idea is: first let the cell input any character, and then in judgment! If you do not determine the number, set the cell to: 0!
Processing judgment in cell cellchanged ();
The code is as follows:
C + + code
void mainwindow::on_tablewidget_cellchanged (int row, int column) { if (column = = 1) return; qtablewidgetitem* item = Ui->tablewidget->item (Row,column); if (!item) return; QString str = Item->text (); Qregexp RxS ("^ ([1-9][0-9]*) $"); if (!rxs.exactmatch (str)) { qmessagebox::about (this,tr ("Waring"), TR ("Please input diagtal"); Item->settext (QString ("0"));} }
Qtablewidgetitem characters that are not numbers can also be entered when editing by default. How