"QT" C + + GUI QT4 Learning Note 2

Source: Internet
Author: User

Go to Cell use QT Desinger to do the interface after the code added to have

Gotocelldialog.h

#ifndef Gotocelldialog_h#defineGotocelldialog_h#include<QDialog>#include"ui_gotocelldialog.h"classGotocelldialog: PublicQdialog, Publicui::gotocelldialog{Q_object Public: Gotocelldialog (Qwidget*parent =0);PrivateSlots:voidon_lineedit_textchanged ();};#endif //Gotocelldialog_h

Gotocelldialog.cpp

#include <QtGui>#include"gotocelldialog.h"Gotocelldialog::gotocelldialog (Qwidget*parent): Qdialog (parent) {SETUPUI ( This); Qregexp RegExp ("[a-za-z][1-9][0-9]{0,2}"); LineEdit->setvalidator (NewQregexpvalidator (REGEXP, This)); Connect (OKButton, SIGNAL (clicked ()), This, SLOT (Accept ())); Connect (CancelButton, SIGNAL (clicked ()), This, SLOT (Reject ()));}voidgotocelldialog::on_lineedit_textchanged () {OKButton->setenabled (lineedit->hasacceptableinput ());}

Main

#include <QApplication>"gotocelldialog.h"int main (int  Char *argv[]) {    qapplication A (argc, argv);     New Gotocelldialog;    Dialog, Show ();     return a.exec ();}

Effect

Sort

Sortdialog.h

#ifndef Sortdialog_h #define Sortdialog_h<QDialog><ui_sortdialog.h>classpublic public  ui::sortdialog{    q_objectpublic:    0);     void Setcolumnrange (Qchar First, Qchar last);}; #endif // Sortdialog_h

Sortdialog.cpp

#include <QtGui>#include"sortdialog.h"Sortdialog::sortdialog (Qwidget*parent): Qdialog (parent) {SETUPUI ( This); Secondarygroupbox-Hide (); Tertiarygroupbox-Hide (); Layout ()-Setsizeconstraint (qlayout::setfixedsize); Setcolumnrange ('A','Z');}voidSortdialog::setcolumnrange (Qchar First, Qchar last) {Primarycolumncombo-Clear (); Secondarycolumncombo-Clear (); Tertiarycolumncombo-Clear (); Secondarycolumncombo->additem (TR ("None")); Tertiarycolumncombo->additem (TR ("None")); Primarycolumncombo->setminimumsize (secondarycolumncombo->sizehint ()); Qchar CH=First ;  while(Ch <=Last ) {Primarycolumncombo-addItem (QString (ch)); Secondarycolumncombo-addItem (QString (ch)); Tertiarycolumncombo-addItem (QString (ch)); CH= Ch.unicode () +1; }}

Main

 #include <qapplication> #include   sortdialog.h   " int  Main (int  argc, char  *argv[]) {qapplication app (argc, argv);    Sortdialog  *dialog =  Sortdialog; Dialog ->setcolumnrange ( c  Span style= "color: #800000;" ", "  f   

"QT" C + + GUI QT4 Learning Note 2

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.