QT 5 Basics 2 (Control article)

Source: Internet
Author: User

    Qvboxlayout *lay = new Qvboxlayout (this);  Create a vertical box



Lebel article

Lay->addwidget (label = new Qlabel ("<a href=www.baidu.com>baidu</a>")); Set up a link to Baidu
    Label->setpixmap (Qpixmap ("1.png"));                         Show bitmap

    Connect (label,&qlabel::linkactivated,[] (QString str) {
        Qdebug () <<str;                                            
    });



Button class
    Lay->addwidget (Button = new Qpushbutton ("button"));
    Button->setstylesheet ("Qpushbutton {font:bold 16px; color:red} ");    
HTML formatting font Red 16 pixels bold is blackbody
    Lay->addwidget (radio = new Qradiobutton ("RadioButton"));
    Radio->setstylesheet ("Qradiobutton {font:bold 16px; color:red} ");
    Lay->addwidget (New Qcheckbox ("Check"));



ComboBox Chapter
    Lay->addwidget (Combox = new Qcombobox ());
    Combox->additem ("1");                                   Add an option
    Combox->additem ("2");                                   Two + options added
    Combox->seteditable (true);                              Set options to edit
    Combox->setcompleter (New Qcompleter (Combox->model ()));  Set default match



    Lay->addwidget (edit = new Qtextedit);
    Edit->settext ("<table border = 1><tr><th>head1</th><th>head2</th></tr > "      
                  "<tr><td>value1</td><td>value2</td></tr>"                     
                  "</table><br>"
    "</img>");
    Edit->setverticalscrollbarpolicy (qt::scrollbarasneeded); Set the value scroll bar, as needed
      IMG src=  Image address abbreviation
         HTML-formatted table border for boundary <tr> Yes row <th> is header <td> is cell
         <table> the beginning of the table <br> line break equals "\ n"


    Slider and Spinbox Articles
    Qslider *slider;
    Lay->addwidget (slider = new Qslider (qt::horizontal));
    Slider->setmaximum (100);
    Slider->setminimum (0);
    Qspinbox *spinbox;
    Lay->addwidget (Spinbox = new Qspinbox);
    Spinbox->setmaximum (100);
    Spinbox->setminimum (0);
    Connect (slider,signal (valuechanged (int)), Spinbox,slot (setValue (int)));   
Connecting Spinbox and Sliders
    Connect (spinbox,signal (valuechanged (int)), Slider,slot (setValue (int)));  
One value change causes the other value to be set



LCD article

    Qlcdnumber *LCD;
    Lay->addwidget (LCD = new Qlcdnumber (10)); Set size
    Lcd->display ("12345:6");                Show numbers or strings
    Lcd->setsegmentstyle (Qlcdnumber::flat); Set paragraph style
    

QT 5 Basics 2 (Control article)

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.