Qtablewidgetitem characters that are not numbers can also be entered when editing by default. How

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.