Skip to content
  • 0 Votes
    2 Posts
    197 Views
    QjayQ

    hey solved using installing following qml packages too

    sudo apt install qml-module-qtquick-extras qml-module-qtquick-controls
  • 1 Votes
    3 Posts
    296 Views
    F

    @jsulm thanks!

    I just added

    target_include_directories(<appName> PUBLIC src)

    what works well.

  • 0 Votes
    2 Posts
    253 Views
    bibasmallB

    As I understand it, the child should receive the event before the parent, but in my case, the child is deaf. I thought maybe the problem was the size of the child, so I set it equal to the parent size, but it didn't help. I can call mousePressEvent(e) directly for the child in the parent's overload, but it looks like a very bad design.

    UPD: currentPrimitive_->setKeepMouseGrab(true); allows to pass the event to the child without ugly direct call of mousePressEvent(e) .

  • 0 Votes
    2 Posts
    379 Views
    Q

    To be more specific, I have a simple tab bar in a applicationWindow like this :

    ApplicationWindow{ id:root width: 800 height: 480 visible: true title: qsTr("Test") SwipeView { id: swipeView anchors.fill: parent currentIndex: tabBar.currentIndex PageAccueil {} PagePcl {} Page3Form {} } footer: TabBar { id: tabBar Material.accent: "#ff9b22" height: 40 currentIndex: swipeView.currentIndex TabButton { text: qsTr("Page 1") } TabButton { text: qsTr("Page 2") } TabButton { text: qsTr("Page 3") } } }

    Here in window, when I click on the footer , the ripple is inside the tab button I clicked on, as it should be. But on linux like I said before the ripple effect is going at the top right of the application.

  • 1 Votes
    1 Posts
    299 Views
    No one has replied
  • 0 Votes
    4 Posts
    589 Views
    C

    I am pretty sure you need to register it to the qmlEngine via

    qmlRegisterType<NotchedRectangle>("My.Items", 1, 0, "NotchedRectangle");

    In your main.cpp, then you should be able to use it. (https://www.qt.io/blog/qml-type-registration-in-qt-5.15)

    In your qml file you can then just type:

    import My.Items

    and then you should be able to use NotchedRectangle

  • 0 Votes
    2 Posts
    201 Views
    sierdzioS

    Yes, you can put any QObject-subclass in as a property (use pointers). Also works with Q_GADGETs.

  • 0 Votes
    1 Posts
    268 Views
    No one has replied
  • 0 Votes
    3 Posts
    2k Views
    I

    They both seem like dead projects, nothing you can rely on.

    grassator/react-qml last commit was Dec 15, 2017
    only 1 contributor, only active 4 years ago.

    ongseespace/react-qml last commit was Mar 26, 2020
    had 2 contributors, most active 3-4 years ago.

    As you may sensed for the extremely few amount of responses before and considering that ReactJS is since many many years one the most prominent JavaScript library in the world, mostly top 1 (https://2021.stateofjs.com/en-US/libraries/front-end-frameworks). It looks not to be in the priority of the Qt strategy.

    Looking at the architecture of Qt, they seem pretty much incompatible. Qt is a complete stack with a complete e2e experience. Where you don't want to mix other stacks or other frameworks.

    That also means, I think, you cannot for example create QML based components that are reusable in other frontend stacks, where the backend may be anything else. QML are closed components.

    So, in other words no support for Web Components specification: https://www.webcomponents.org/introduction
    which was created to be able to produce reusable components.

    If anybody, disagrees or have more insights, happy to know about it :)

  • 0 Votes
    7 Posts
    682 Views
    G

    @sierdzio

    Ok now it's much clearer, thank you again.

    It looks like there is a lot of documentation to read, but apparently most things I have in mind should work. Still, for some reason, I feel QWidgets will perform faster. I'll try to make some tests and get back here.

    Thank you again!

  • 0 Votes
    5 Posts
    901 Views
    V

    @J-Hilk
    Ok that's enough I think.

    One more question what will happen to scrolleft().

    If I keep on incrementing these, will there be any increase in runtime memory or processor load?

  • 0 Votes
    1 Posts
    275 Views
    No one has replied
  • 0 Votes
    7 Posts
    2k Views
    K

    @J-Hilk

    I got it to work with ifw as well. However, the option --plugindir apparently does not work correctly. The plugins were stored in the folder of the exe.

    However, also the installation using ifw was finally successful.

  • 0 Votes
    4 Posts
    2k Views
    K

    The only solution I found is with inheriting from QStringListModel.

    main.cpp

    #include <QGuiApplication> #include <QQmlApplicationEngine> #include <QQmlContext> #include <QSettings> #include "MyStringListModel.h" #include <QDebug> int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; const QUrl url(QStringLiteral("qrc:/main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); qmlRegisterType <MyStringListModel> ( "StringListModel", 1, 0, "MyStringListModel" ); MyStringListModel lstModel; QSettings settings ( "TestQml.ini", QSettings::IniFormat ); lstModel.readSettings(&settings, "Components"); if ( lstModel.stringList().size() < 1 ) { lstModel.setStringList( QStringList() << "Test 1" << "Test 2"); lstModel.setCurrentIndex(0); } qDebug() << lstModel.stringList(); engine.rootContext()->setContextProperty ("myLstModel", &lstModel ); engine.load(url); return app.exec(); }

    MyStringListModel.h

    #ifndef MYSTRINGLISTMODEL_H #define MYSTRINGLISTMODEL_H #include <QObject> #include <QStringListModel> class QSettings; class MyStringListModel : public QStringListModel { Q_OBJECT Q_PROPERTY (int CurrentIndex READ getCurrentIndex WRITE setCurrentIndex NOTIFY sigCurrentIndex ) int CurrentIndex; public: MyStringListModel(); int getCurrentIndex () const; void setCurrentIndex ( int indx ); void readSettings ( QSettings *settings, const QString & category ); void writeSettings ( QSettings *settings, const QString & category ) const; public slots: void addNewText ( QString editText ); void sltEditText ( QString editText ); signals: void sigCurrentIndex(); }; #endif // MYSTRINGLISTMODEL_H

    MyStringListModel.cpp

    #include "MyStringListModel.h" #include <QSettings> MyStringListModel::MyStringListModel() : CurrentIndex ( 0 ) { } int MyStringListModel::getCurrentIndex() const { return CurrentIndex; } void MyStringListModel::setCurrentIndex(int indx) { CurrentIndex = indx; } void MyStringListModel::addNewText(QString editText) { const QStringList &lst = stringList(); for ( int i = 0; i < lst.size(); ++i ) { if ( editText == lst[i] ) return; } setStringList ( stringList() << editText ); setCurrentIndex ( rowCount() - 1 ); } void MyStringListModel::readSettings(QSettings *settings, const QString &category) { settings->beginGroup(category); QStringList lst = settings->value("Entries", QStringList()).toStringList(); setStringList ( lst ); int currentIndex = settings->value("CurrentPosition", 0 ).toInt(); setCurrentIndex(currentIndex); settings->endGroup(); } void MyStringListModel::writeSettings(QSettings *settings, const QString &category) const { settings->beginGroup(category); settings->setValue("Entries", stringList()); settings->setValue("CurrentPosition", CurrentIndex ); settings->endGroup(); } void MyStringListModel::sltEditText(QString editText) { addNewText ( editText ); QSettings settings ( "TestQml.ini", QSettings::IniFormat ); writeSettings(&settings, "Components"); }

    main.qml

    import QtQuick 2.15 import QtQuick.Controls 2.15 import StringListModel 1.0 ApplicationWindow { width: 640 height: 480 visible: true title: qsTr("Scroll") Frame { ComboBox { id: secondComboBox editable: true model: myLstModel currentIndex: model.CurrentIndex textRole: "display" onAccepted: { if (find(editText) === -1) model.addNewText ( editText ) } } } }