Git Product home page Git Product logo

maxlibqt's Introduction

maxLibQt - C++ and QML code library for the Qt™ framework.

This is a (growing) collection of somewhat random C++ classes and QtQuick QML modules for use with the Qt™ framework.

They are free to use in other open source projects under the terms of the GNU Public License (GPL). For use in commercial or other closed-source software, you need to contact me for a license agreement. See the LICENSE.txt file.

The original target Qt library version was 5.2+. Newer components, and some that have been updated more recently, may require a later version, at least 5.9 (if you run into something that could be made more backwards-compatible, let me know). Most (if not all) of the C++ code requires C++11 at minimum.

Project home: https://github.com/mpaperno/maxLibQt

C++ Components:

  • Core
    • AppDebugMessageHandler - Custom debug/message handler class to work in conjunction with qDebug() family of functions.
  • Item Models
    • GroupedItemsProxyModel - A proxy model (QIdentityProxyModel subclass) which allows a grouped tree-based item presentation of a flat table data model. Typically used for visually grouping items by some shared criteria, like a category or subject. Useful in a QTreeView or the TreeComboBox from this collection.
  • Layouts
    • OverlayStackLayout - A QStackedLayout with additional features to allow stacks with "floating" overlay widgets, such as toolbars, buttons, messages, etc., while still allowing interaction with exposed areas of the widget(s) underneath. Includes a functional image viewer example application.
  • Widgets
    • ActionPushButton - A QPushButton which takes a default QAction, just like a QToolButton can.
    • BuddyLabel - A QLabel with enhanced "buddy" capabilities like click redirect and tooltip inheritance.
    • CollapsingToolBar - A QToolBar which toggles between ToolButtonIconOnly and ToolButtonTextBesideIcon styles based on available width.
    • ExportableTableView - A QTableView with features to export data as plain text or HTML.
    • RoundedMessageBox - A frameless QMessageBox implementation, fully stylable via CSS or QPalette.
    • ScrollableMessageBox - A simple message box with a large scrollable area (a QTextEdit) for detailed text (including HTML formatting).
    • TimerEdit - A time value line editor which accepts negative and large times (> 23:59:59), suitable for a timer, etc.
    • TreeComboBox - A QComboBox control which works with a tree-based data model & view, allowing drill-down selection of items.

QML Components:

  • Controls
    • MLDoubleSpinBox - A SpinBox control which handles float/double number types to the desired precision, as well as large integers (within ECMAScript limits). Avoids the int size type limitation of the current QtQuick Controls (v2.0 - 2.4) SpinBox but still using the current theme styling (Fusion/Material/etc).
    • MLHexSpinBox - A SpinBox control which allows editing integers in hexadeciaml format. Allows a wide range of numbers, including unsigned integers. Based on MLDoubleSpinBox.

Documentation:

Some Doxygen-style documentation is embedded in the code and can be generated as either part of the CMake build or manually with the included Doxyfile (run doxygen doc/Doxyfile in root of this project). To generate docs for QML code you'd need to use install doxyqml (the Doxyfile is already configured to use it if you have it). Some of the source code is further documented inline (but never enough).

This documentation is also published at https://mpaperno.github.io/maxLibQt/

Building (C++):

Both CMake and qmake project files are provided. They're set up to be built as individual libraries split by base folder (core, item models, etc). With CMake you can also build one library file which contains all the others (haven't figured out how to do that with qmake yet).

You can also simply include whichever C++ module(s) you need into your own project. They're standalone unless specifically mentioned otherwise in their docs. There are also .pri qmake files for each source folder which could be used to quickly include all modules in that folder (and add to the INCLUDEPATH).

Using (QML)

Simplest way to use the QtQuick modules would be to copy them into your code tree.

To use them as external ("library") imports in your code, put the maxLibQt folder (from inside the /src/quick/ folder of this project) into the QML search path for your app. Then, for example to use MLDoubleSpinBox, you'd specify import maxLibQt.controls 1.0 in your QML.


Author

Maxim Paperno
https://github.com/mpaperno/
http://www.WorldDesign.com/contact

Please inquire about custom C++/Qt development work.

Copyright, License, and Disclaimer

Copyright (c) Maxim Paperno. All rights reserved.

See LICENSE.txt file for license details.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Qt is a trademark of The Qt Company with which neither I nor this project have any affiliation.

maxlibqt's People

Contributors

mpaperno avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

maxlibqt's Issues

Prefix and Suffix properties for MLDoubleSpinBox

Your implementation of the DoubleSpinBox for Qt Quick Controls 2 is very interesting. Thanks!
But in order to port code using Qt Quick Controls 1, one would need the support for the prefix and suffix properties.
As mentioned in the doc: prefix and suffix.

I have added it to the floating point SpinBox example from Qt Quick Controls 2 doc like this:

    property string prefix: ''
    property string suffix: ''
    
    [...]

    textFromValue: function(value, locale) {
        return prefix + Number(value / 100).toLocaleString(locale, 'f', decimals) + suffix
    }

    valueFromText: function(text, locale) {
        var numberStr = text.replace(suffix, '').replace(prefix, '');
        return Number.fromLocaleString(locale, numberStr) * 100
    }

Make compatible with Qt 6

Some types have been renamed in Qt 6, for instance "RegExValidator" got "RegularExpressionValidator".

MLDoubleSpinBox

Hello! Оnce again) Playing around with MLDoubleSpinBox I have found that it's text field does not updates properly if you enter value out of [from - to] range more than one time.

For the instance, let's use "controls/test.qml". MLDoubleSpinbox instance with "Default" label prepared to work in range from 0 to 10.

Step 1. Preview qmlscene
image

Step 2. Write, for the instance, 20 in the text field by keyboard
image

Step 3. Press 'Enter', value adjusted to top limit - it is ok, as expected
image

Step 4. Once again write 20, or whatever
image

Step 5. Press 'Enter', oops - it is not working now (
image

Step 6. Even if I change focus, MLDoubleSpinBox still contains 20
image

My specs.: MS Windows7x64
Qt: 5.9.1, 5.12.2
Compiller: Mingw32

MLDoubleSpinBox in Qt 5.12.2

Hello. I have found this while updating from Qt 9.1 to Qt 5.12.2

MLDoubleSpinBox has been used as delegate:

MLDoubleSpinBox {
                from: model.min
                to:   model.max
                stepSize: model.stepsize
                onValueChanged: model.value = value
                wrap: false
            }

In Qt 5.9.1 it works great as expected:
MLDoubleSpinBox works in qt_5 9 1

But not in Qt 5.12.2 (same model as in the above example):
MLDoubleSpinBox issue in qt_5 12 2

OS: Win7x64
Compiler: Mingw5.3x86 for Qt5.9.1 and Mingw7.3x86 for Qt5.12.2

Thank you for the code sharing!

MLDoubleSpinBox

Hi. I am writing my first QML application and am running into troubles. I am using your MLDoubleSpin box and it behaves slightly differently than the SpinBox. I am hoping you will see my mistake if I have one.

What I have works, until I press the + or - buttons on the spinbox. It then appears to overwrite my value and will no longer pull up the value from the c++ code. As far as I can tell, the SpinBox which uses integers, doesn't have this behaviour.

QML UI file
'ComboBox {
id: comboBox1
anchors.right: parent.right
anchors.rightMargin: 40
anchors.verticalCenter: parent.verticalCenter
textRole: "key"
valueRole: "value"
model: ListModel {
ListElement {
key: "7/8, 50 ohm"
value: 1
}
ListElement {
key: "1 5/8, 50 ohm"
value: 2
}
}
onCurrentValueChanged: _page3.preset = currentValue
}
.........
MLDoubleSpinBox {
id: spin3
anchors.right: parent.right
anchors.margins: 10
decimals: 3
from: 0
to: 30
value: _page3.outer
onValueChanged: _page3.outer = value
stepSize: 0.1
}
'

c++ header
'class CalcP3: public QObject
{
Q_OBJECT
Q_PROPERTY(double outer READ getOuter WRITE setOuter NOTIFY update)

.......
}'

c++ class
{
void CalcP3::setPreset(double value){
if (value == m_preset) return;
m_preset = value;
switch(m_preset) {
case 1:
m_outer = 0.785;
m_inner = 0.341;
break;
case 2:
m_outer = 1.527;
m_inner = 0.664;
break;
}
emit update();
}

........
'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.