QT开源库

https://github.com/victronenergy/QsLog

https://github.com/mkroening/qslog

QsLog - the simple Qt logger

QsLog is an easy to use logger that is based on Qt's QDebug class. QsLog is released as open source, under the MIT license.

###Contribution policy### Bug fixes are welcome, larger changes however are not encouraged at this point due to the lack of time on my side for reviewing and integrating them. Your best bet in this case would be to open a ticket for your change or forking the project and implementing your change there, with the possibility of having it integrated in the future. All contributions will be credited, license of the contributions should be MIT.

Features

  • Six logging levels (from trace to fatal)
  • Logging level threshold configurable at runtime.
  • Minimum overhead when logging is turned off.
  • Supports multiple destinations, comes with file and debug destinations.
  • Thread-safe
  • Supports logging of common Qt types out of the box.
  • Small dependency: just drop it in your project directly.

Usage

  • Include QsLog.h. Include QsLogDest.h only where you create/add destinations.
  • Get the instance of the logger by calling QsLogging::Logger::instance();
  • Optionally set the logging level. Info is default.
  • Create as many destinations as you want by using the QsLogging::DestinationFactory.
  • Add the destinations to the logger instance by calling addDestination.

Note: The logger does not take ownership of the destinations. Make sure that the destinations still exist when you call one of the logging macros. A good place to create the destinations is the program's main function.

Disabling logging

Sometimes it's necessary to turn off logging. This can be done in several ways:

  • globally, at compile time, by enabling the QS_LOG_DISABLE macro in the supplied .pri file.
  • globally, at run time, by setting the log level to "OffLevel".
  • per file, at compile time, by including QsLogDisableForThisFile.h in the target file.

Thread safety

The Qt docs say: A thread-safe function can be called simultaneously from multiple threads, even when the invocations use shared data, because all references to the shared data are serialized. A reentrant function can also be called simultaneously from multiple threads, but only if each invocation uses its own data.

Since sending the log message to the destinations is protected by a mutex, the logging macros are thread-safe provided that the log has been initialized - i.e: instance() has been called. The instance function and the setup functions (e.g: setLoggingLevel, addDestination) are NOT thread-safe and are NOT reentrant.

https://github.com/MEONMedical/Log4Qt

libmodbus

https://github.com/stephane/libmodbus

https://github.com/cmjones01/libmodbus (异步Async    https://martin-jones.com/2015/12/16/modifying-libmodbus-for-asynchronous-operation/

https://github.com/ed-chemnitz/qmodbus

https://github.com/Jihadist/QModMaster

https://github.com/Thuzerland/qModbusMaster

https://github.com/Hegemony230/Qt_TCP_modbus

界面参考

https://github.com/yuxshao/ptcollab

TODO

QListView

https://github.com/Longxr/QListViewDemo


QStandardItem
treeView

https://github.com/Poofee/qtprojects/tree/master/TreeDemo13

https://github.com/Poofee/qtprojects/tree/master/treeviewsimple

https://github.com/viafx24/Test_QStandardItemModel_QTreeView

https://github.com/zz2summer/qt-books-learning

Json解析

https://github.com/mbcarruthers/post_fetcher

https://github.com/ahmetkotan/QT-Json-Example

https://blog.csdn.net/Easadon/article/details/108266030

https://github.com/gil9red/table_save_load_as_json

https://github.com/dridk/QFormJson

https://github.com/cjmdaixi/QuickJSONViewer

QQuickItem * FluxHub::createObjectNode(QQuickItem *currentItem, const QString &key, const QJsonObject &jsonObj, int level)
{
    auto objectNode = createLevelItem(level, currentItem);
    setNodeText(objectNode, key);

    for(auto it = jsonObj.begin(); it != jsonObj.end(); ++it){
        auto child = it.value();
        auto childName = it.key();
        auto childType = it.value().type();

        QQuickItem *rt = nullptr;
        if(childType == QJsonValue::Object){
            rt = createObjectNode(objectNode, childName, child.toObject(), level + 1);

        }
        else if(childType == QJsonValue::Array){
            rt = createArrayNode(objectNode, childName, child.toArray(), level + 1);
        }
        else{
            rt = createLeafNode(objectNode, childName, child, level + 1);
        }
        if(rt == nullptr){
            qWarning()<<"Create child node error!"<<childName<<childType;
            return nullptr;
        }
    }
    return objectNode;
}

https://blog.csdn.net/m0_47500475/article/details/107745426

QT遇到“qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed” 问题

https://blog.csdn.net/xbpalyer/article/details/103228967

qt里一些spinbox与滑动条之类在数据变化时刷新的一些小细节

setKeyboardTracking(False)

https://www.cnblogs.com/grandyang/p/6263929.html

https://stackoverflow.com/questions/17512542/getting-multiple-inputs-from-qinputdialog-in-qtcreator

QInputDialog Multiple Inputs 输入多个变量的对话框

QDialog dialog(this);
// Use a layout allowing to have a label next to each field
QFormLayout form(&dialog);

// Add some text above the fields
form.addRow(new QLabel("The question ?"));

// Add the lineEdits with their respective labels
QList<QLineEdit *> fields;
for(int i = 0; i < 4; ++i) {
    QLineEdit *lineEdit = new QLineEdit(&dialog);
    QString label = QString("Value %1").arg(i + 1);
    form.addRow(label, lineEdit);

    fields << lineEdit;
}

// Add some standard buttons (Cancel/Ok) at the bottom of the dialog
QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
                           Qt::Horizontal, &dialog);
form.addRow(&buttonBox);
QObject::connect(&buttonBox, SIGNAL(accepted()), &dialog, SLOT(accept()));
QObject::connect(&buttonBox, SIGNAL(rejected()), &dialog, SLOT(reject()));

// Show the dialog as modal
if (dialog.exec() == QDialog::Accepted) {
    // If the user didn't dismiss the dialog, do something with the fields
    foreach(QLineEdit * lineEdit, fields) {
        qDebug() << lineEdit->text();
    }
}

QT提升用法  自定义控件

https://blog.csdn.net/ShenHang_/article/details/104942782

https://blog.csdn.net/qq_14945437/article/details/98730805

原文地址:https://www.cnblogs.com/sinferwu/p/14832871.html