Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Qt skills

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to use Qt skills". In daily operation, I believe many people have doubts about how to use Qt skills. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how to use Qt skills". Next, please follow the editor to study!

If you use a sqlite database and do not want to generate database files, you can create an in-memory database.

QSqlDatabase db = QSqlDatabase::addDatabase ("QSQLITE"); db.setDatabaseName (": memory:")

Empty the data table and reset self-incrementing ID,sql = truncate table table_name.

The Qtchart module comes with Qt5.7, and the minimum compilation requires Qt5.4. Remember to check it when installing, but leave it unchecked by default. Using this module requires the introduction of namespaces.

# include QT_CHARTS_USE_NAMESPACEclass CustomChart: public QChartView

QPushButton left-aligned text, need to set stylesheet QPushButton {text-align:left;}

There are three ways to set text in QLabel. Mastering the attribute system of Qt, using examples as examples, can make a lot of effects.

Ui- > label- > setStyleSheet ("qproperty-text:hello;"); ui- > label- > setProperty ("text", "hello"); ui- > label- > setText ("hello")

By cleverly opening the event loop with QEventLoop, you can get the returned results synchronously without blocking the interface. A new thread execution is created inside QEventLoop.

QEventLoop loop;connect (reply, SIGNAL (finished ()), & loop, SLOT (quit (); loop.exec ()

Multiple predefined variables # if (defined webkit) | | (defined webengine).

The new version of Qtcreator enhances syntax checking, will pop up a lot of warning prompts, etc., you can turn off the first few clang in the plug-in list, Help "About Plugins. You can also set the code review level, Tools "Options" C++ Code Model.

QSqlTableModel's rowCount method returns a maximum of 256by default. If it exceeds 256, you can pull the table to the bottom and automatically load the remaining 256pieces of data at a time. If you need to print or export data, you'd better use SQL statement to query, instead of using QSqlTableModel's rowCount method. Otherwise, only 256 pieces of data will be exported at the maximum. If the amount of data is small, you can also use the following methods:

/ / load all data actively, otherwise the number of rows obtained is canFetchMore () {model- > fetchMore ();}

If you need to specify a borderless form, but you need to retain the border features of the operating system, you can stretch the border freely and use setWindowFlags (Qt::CustomizeWindowHint)

At this point, the study of "how to use Qt skills" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report