The Sort And Operator[] Of QMap

sort The QMap object sorts the elements in it by key rather than the order of insert operation. Let’s see the following example. #include <iostream> #include <QMap> #include <QString> using namespace std; int main() { QMap<QString, int> vars; vars.insert( “ABD”, 1 ); vars.insert( “ABE”, 2 ); QMapIterator<QString, int> it( vars Read more…

QT – Common Setting For Window

Borderless window: setWindowFlags( Qt::FramelessWindowHint ); Set background color: QPalette pal = mainWin->Getui().qvtkWidget->palette(); pal.setColor( QPalette::Background, Qt::black ); setAutoFillBackground( true ); this->setPalette( pal ); Make window stay on the top level: setWindowFlags(Qt::WindowStaysOnTopHint) Remove maximize button in widget: setWindowFlags( this->windowFlags() & ~Qt::WindowMaximizeButtonHint ); Definite buttons on title bar: setWindowFlags( Qt::CustomizeWindowHint | Qt::WindowMaximizeButtonHint); //Only Read more…

QT – QTest event, QSignalSpy and installEventFilter

The interfaces can imitate users’ operations. QTest::keyClick QTest::keyPress QTest::mouseClick QSignalSpy listens for signal emission, it is a list of QVariant lists. It will not shield off signal to make slot invalid. QCheckBox *box = …; QSignalSpy spy(box, SIGNAL(clicked(bool))); //… QList arguments = spy.takeFirst(); // take the first signal QVERIFY(arguments.at(0).toBool() == Read more…

Unit Test Based On QT

Simple Unit Test Project Let’s create a new unit test project firstly. Write our test functions in feild private Q_SLOTS for the class. tst_string.cpp: #include <QString> #include <QtTest> class String : public QObject { Q_OBJECT public: String(); private Q_SLOTS: void toUpper(); }; String::String() { } void String::toUpper() { QVERIFY2(true, “Failure”); Read more…

Tex To PDF
: convert the Latex file which suffix is tex to a PDF file

X