Skip to content
  • 0 Votes
    5 Posts
    305 Views
    O

    @JonB

    But you talk about "The purpose is to have different lines/coloring for each line". That implies to me you do want multiple, separate line series, each with their own points and color?

    Yes.

    In that case you do want new QLineSeries created each time round the loop, so you end up with 5 lines (and get rid of the wasted one outside the loop).

    Okay, thank you. I did this and with a little bit of refactoring I got it to work as expected. Appreciate the assistance!

  • 0 Votes
    2 Posts
    413 Views
    Y

    I've managed to deploy a test app from Monterey which works on Catalina and Monterey and given up on building on Catalina after spending a few days trying to fix the result of macdeployqt using otool and install_name_tool.

    It seems that the CMake qt_generate_deploy_app_script method doesn't work when run from Monterey either. Running the macdeployqt utility almost works out of the box, it just leaves the plugins' RPATH pointing to a nonexistent 'lib' folder where it expects Qt frameworks to be. Rather than fix the RPATH's in each of those plugin libs, adding a 'lib' symlink pointing to the Frameworks folder seems to do the trick.

    In case it's useful to anyone, I've made a template repository on GitHub with this solution. The template allows you to deploy apps with LGPL Qt on Mac and Windows and use VSCode as an IDE rather than QtCreator:

    https://github.com/yergin/qt-cmake-vscode

  • 0 Votes
    13 Posts
    1k Views
    SGaistS

    Libraries that are shared between plugins and executable shall be shared and not static. Otherwise you will end up with multiple definition of the static meta object of your QObject based classes which is not good.

  • 0 Votes
    1 Posts
    461 Views
    No one has replied
  • 0 Votes
    1 Posts
    239 Views
    No one has replied
  • 1 Votes
    4 Posts
    665 Views
    jeremy_kJ

    Do these objects output by the factory have a lifetime that needs to exceed the QML component used for the object's controls? If not, I would make the object a QML (not Quick) type, and have the component that displays the controls also instantiate the object.

    Even if they do have lifetimes that don't match the UI portion, the controls can be thin wrappers around the objects that really implement the backend. In the example below RadioBackend and TapeBackend are QObject derived classes that export Q_INVOKABLE functions and properties for communication with the UI. Register them with one of the qmlRegister* functions, depending on the desired interface.

    For example:

    Radio.qml:

    Rectangle { color: control.colorTheme RadioBackend { id: control } Row { Button { onClicked: control.doAction() } Button { onClicked: control.doOtherAction() } } }

    TapeDeck.qml:

    Rectangle { color: control.colorTheme TapeBackend { id: control } Button { onClicked: control.doTapeAction() } }

    main.qml:

    Loader { property MediaType mediaType source: mediaType === MediaType.Radio ? "file://Radio.qml" : "file://TapeDeck.qml" }
  • 0 Votes
    1 Posts
    258 Views
    No one has replied
  • 0 Votes
    1 Posts
    559 Views
    No one has replied
  • Dynamic circles/dots

    Unsolved QML and Qt Quick
    5
    0 Votes
    5 Posts
    482 Views
    B

    If I create the dots dynamically, are there different ways of doing it? I have never done that before.

  • 0 Votes
    2 Posts
    899 Views
    VRoninV

    f3 = new QFrame();

    ???

    How can I have a fixed size for the buttons for both the situations?

    c->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);

  • 0 Votes
    21 Posts
    6k Views
    K

    @SGaist Thanx mate :) Qt rox :D

  • 0 Votes
    11 Posts
    12k Views
    K

    @jsulm thanx bro :)

  • 0 Votes
    3 Posts
    5k Views
    jsulmJ

    @Lasith Well, emit a signal, pass the current value to it as parameter. Connect the signal to the slot.

    // somewhere in your code connect(this, SIGNAL(mySignal(int)), otherObject, SLOT(mySlot(int))); for (int i = 0; i < 10; ++i) { emit mySignal(i); } // In the other class void MyObject::mySlot(const int value) { // Do something }

    Did you read http://doc.qt.io/qt-5.9/signalsandslots.html ?

    Actually you should think about the need of signals and slots in this particular case - maybe it will be much easier and faster to directly call a method from the other class instead of emitting a signal? Signals/slots are useful if you want to have loose coupling, so the sender does not need to know anything about receiver.

  • 0 Votes
    9 Posts
    2k Views
    mrjjM

    Hi
    While walking my imaginary dog, i was wondering if the
    number you input "ui->values->text().toInt()"
    means how many names/ages to get and you mean for it
    to ask that many times, and not really create that many
    dialogs ?
    So like ask me 10 times
    and one and the same dialog would show up 10 times ?
    And each time, user press ok, it would save the data, then
    show again ?

  • 0 Votes
    2 Posts
    1k Views
    p3c0P

    @monster You can create the TextInput using createComponent and then after creating its object you can assign it to a js variable. You can store them for eg. in an array for further reference.

    var component = Qt.createComponent("MyTextInput.qml"); var textinput = component.createObject(parent);
  • 0 Votes
    9 Posts
    6k Views
    kshegunovK

    @Dong
    Hello,
    Sorry for the late reply. Yes, you've got the essence of it. Qt's containers (QList included) are pretty smart in respect to copying, they will not copy the actual data until you change it. They are implicitly shared. This is done so you can return and copy the container many times, but in actuality internally only a pointer is reassigned and reference counter updated. When you call a non-const function on that list, Qt checks the reference counter and if more than one object is attached to the data, then and only then the data is detached (copied). When you put your list in the QVariant it is stored by value (making a shallow copy), but QVariant will return a shallow copy as well (meaning the data will not be changed, only the internal pointer reassigned and reference counter incremented).

    Now, for your particular case:
    The first line of code works, because you don't modify the list, but take an element (which is a pointer) and modify the object the list is holding reference to. This doesn't cause the list data to be copied. The second line you have, doesn't work, because you're changing the list data (assigning a new value to a list's element), which causes the list data to be detached and in practice, you're operating on a completely different set of data.

    Here is a reference if you're interested in the way QList and other containers manage their data, and what implicit sharing is.

  • 0 Votes
    2 Posts
    1k Views
    p3c0P

    Hi @Pisko and Welcome,

    The first problem is that I don't know how to definite the button id if i create them dynamically so I cannot identify which buttons are pressed to save the answers in the database.

    Unfortunately you cant assign an id for dynamically created items. Check this for more details.

    Another problem is that I cannot create Exclusive Groups dynamically.

    I think you can use a ExclusiveGroup here.

  • 0 Votes
    4 Posts
    2k Views
    p3c0P

    @Mephi Hmm, sorry for that. I wasn't aware of it as i have never used it before. So digging in it seems that the attached properties of DelegateModel doesn't seem to work if the delegate is in separate file. Could be a bug I suppose. You can try reporting it here.

  • 0 Votes
    5 Posts
    3k Views
    mrjjM

    @Basstrom

    Hi both ways would work with different information.
    It is possible to give each widget a name with number if needed.

    But if you are aiming for something that would be a table then
    it is far more work to create a widget for each column than to
    use a QTableWidget as sgaist suggests.

    ui->table->setRowCount ( 1 ); ui->table->setColumnCount ( 3 ); ui->table->setSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding ); ui->table->setHorizontalHeaderLabels ( QString ( "Name;Track Time;Prev Track Time" ).split ( ";" ) ); //Add Table items here ui->table->setItem ( 0, 0, new QTableWidgetItem ( "Michael Schumacher" ) ); ui->table->setItem ( 0, 1, new QTableWidgetItem ( "22.55" ) ); ui->table->setItem ( 0, 2, new QTableWidgetItem ( "44.3" ) );