Skip to content

Brainstorm

Stuck? Some ideas just need to be dumped on someone before they can materialize.
439 Topics 3.2k Posts
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    11 Views
    No one has replied
  • Which QT framework for dashboard of ship

    Unsolved
    4
    0 Votes
    4 Posts
    535 Views
    SGaistS

    That's good to know.

    In that case, depending on the fanciness you want, Qt Quick is still a good option as it allows for more visual effects and they would be easier to implement than with widgets. Otherwise the graphics view framework will also be of interest.

    On what kind of device will your dashboard run ?

    KDAB has built something for boats.

  • Implementing many-to-many relationships

    Solved
    40
    0 Votes
    40 Posts
    10k Views
    TomZT

    @mzimmers said in Implementing many-to-many relationships:

    Doesn't seem to me that I'd need new/delete anyway, but I do agree that it seems preferable to:

    create and maintain a map of Equipment objects (or structs) with a UUID as the key
    in the Activity object, maintain a list of Equipment UUIDs.

    Is this what you had in mind?

    The various comments here went towards using pointers to instances of classes as the relationship. Can't use a raw pointer (safely) without 'new'.

    If your only objects are the Equipment and the Activity, then yeah, that's pretty simple.

    as this got confusing, here is a very quick and dirty mockup I just wrote in 5 minutes. Apologies for the roughness.

    struct PActivity; struct PEquipment; class ManagerPrivate { public: std::map<int, PActivity> m_activities; std::map<int, PEquipment> m_equipments; int m_lastAssignedId = 0; }; struct PActivity { QString name; }; struct PEquipment { QString name; std::deque<int> activities; }: class Manager { public: ManagerPrivate *d; Activity createActivity(); }; // ---- class Activity { public: explicit Activity(Manager *parent, int n); Activity(); // gives invalid instance. bool isValid() const { return d && n; } QString name() const { assert(isValid()); auto i = d->m_activities.find(n); assert(i != d->m_activities.end()); return i->name; } void setName(const QString &name) { assert(isValid()); auto i = d->m_activities.find(n); assert(i != d->m_activities.end()); i->name = name; } int id() const { return n; } private: ManagerPrivate *d = nullptr; int n = 0; }; class Equipment { explicit explicit(Manager *parent, int n); explicit(); // gives invalid instance. bool isValid() const; QString name() const; void setName(const QString &name); void addActivity(const Activity &a) { assert(a.isValid()); assert(isValid()); auto i = d->m_equipments.find(n); assert(i != d->m_equipments.end()); i->activities.push_back(a->id()); } private: ManagerPrivate *d = nullptr; int n = 0; }
  • 0 Votes
    2 Posts
    262 Views
    Kent-DorfmanK

    in my 30+ years of experience taking over someone elses app usually means throwing it out the nearest airlock and doing it from scratch "correctly". The previous owner never knew what the tar they were doing. LOL

  • need suggestions for transition/animation of banner

    Solved
    7
    0 Votes
    7 Posts
    560 Views
    mzimmersM

    @sierdzio yes, that seemed to fix it.

    Item { id: banner property int bannerHeight: 80 implicitHeight: (opMode.mode === OpModes.Service) || (navBar.tabIndex === 3) ? bannerHeight : 0 Behavior on implicitHeight { NumberAnimation { duration: 250 } } Layout.fillWidth: true Rectangle { id: rect anchors { left: parent.left right: parent.right } implicitHeight: parent.implicitHeight ... } }

    I think I need to apply a similar animation to the opacity of the contents of the Rectangle (a couple lines of text and a Button), but I get the principle now.

    Thanks to all for the help.

  • Update C++ list model from QML

    Solved
    11
    0 Votes
    11 Posts
    2k Views
    ChronalC

    You can use a QAbstractListModel to update the list model from QML. The QAbstractListModel provides an interface for accessing data from a list of items. It can be used to update the list model from QML by using the setData() method.

    To update the list model from QML, you will need to create a QAbstractListModel subclass and implement the setData() method. The setData() method should take the index of the item to be updated and the new value for the item. You can then call the setData() method from QML to update the list model.

    For example, if you have a list of strings, you can create a QAbstractListModel subclass and implement the setData() method as follows:

    void MyListModel::setData(const QModelIndex &index, const QVariant &value, int role)
    {
    if (index.isValid() && role == Qt::EditRole) {
    int row = index.row();
    QStringList list = data(index, Qt::DisplayRole).toStringList();
    list[row] = value.toString();
    setData(index, QVariant::fromValue(list), Qt::DisplayRole);
    }
    }

    You can then call the setData() method from QML to update the list model. For example:

    MyListModel {
    id: myListModel
    // ...
    }

    Button {
    text: "Update List Model"
    onClicked: {
    myListModel.setData(myListModel.index(0, 0), "New Value", Qt.EditRole);
    }
    }

    This will update the first item in the list model with the new value.

  • What kind of overviews do you miss in the Qt documentation?

    Unsolved
    20
    2 Votes
    20 Posts
    2k Views
    T

    Qt samples are not large enough. Include a few Qt-based open source applications and provide detailed step-by-step instructions.

  • Register a Qt account twice

    Unsolved
    2
    0 Votes
    2 Posts
    430 Views
    SGaistS

    Hi,

    You should open a ticket about that matter in your Qt account page. This is a user forum and there you need the Qt Company admins help.

  • Passing data structures from QML to C++

    Solved
    10
    0 Votes
    10 Posts
    2k Views
    JKSHJ

    (Further questions forked to https://forum.qt.io/topic/142227/update-c-list-model-from-qml )

  • Running ROS2 using QT5

    Solved
    9
    0 Votes
    9 Posts
    3k Views
    serkan_trS

    @JoeCFD yes I tried but the libraries I added are used for ROS1. so ROS2 also bases these jobs on ament_cmake so it gave errors.
    I solved the problem by cmake and moved forward
    Sample code for ROS2

    Screenshot from 2024-07-03 09-03-13.png

  • Ideas for modulize my code using qt for another qt project.

    Unsolved
    2
    0 Votes
    2 Posts
    314 Views
    jsulmJ

    @fromis_9 said in Ideas for modulize my code using qt for another qt project.:

    so this doesn't seem appropriate

    Why? If the other project is also based on Qt there is no problem to use a shared library which depends on Qt.

  • need ideas on styling a ListView

    Solved
    27
    0 Votes
    27 Posts
    4k Views
    mzimmersM

    For anyone who might be reading this for an answer to their own question, I looked at @TomZ 's solution, and realized that I had a bug in my delegate - my text centering wasn't taking the rounded corners effectively adding height to the top and bottom rows. I had to alter my delegate:

    Component { id: activityDelegate Rectangle { height: { var h = rect1.rowHeight; if (index === 0 || index === (activityModel.count - 1)) h -= rect1.radius return h; } width: rect1.width color: rect1.color Text { text: model.parameter anchors { left: parent.left leftMargin: parent.height / 2 verticalCenter: parent.verticalCenter verticalCenterOffset: { var o = 0; if (index === 0) o -= (radius / 2) else if (index === (activityModel.count - 1)) o += (radius / 2) return o; } } font.pixelSize: 14 font.bold: true } Styledswitch { id: onOff visible: model.switchVisible anchors { right: parent.right rightMargin: parent.height / 2 verticalCenter: parent.verticalCenter } } } }

    As always, if this doesn't look right, please let me know, and I'll fix it.

  • 0 Votes
    3 Posts
    381 Views
    mzimmersM

    @TomZ yeah, I think I won't have to accommodate huge resolution differences, maybe from 800x480 to 1280x800 or so. I've already taken the approach of using separate files for classes. Not sure the Flow layouts will work, but I'll look into it.

    Thanks for the suggestions...

  • need a slick way of "hiding" my FontLoaders

    Solved
    11
    0 Votes
    11 Posts
    1k Views
    mzimmersM

    @JoeCFD I found the problem - I needed this line in my main.cpp:

    qmlRegisterSingletonType( QUrl( "qrc:/assets/Style.qml" ), "styles.stylesheet", 1, 0, "Style" );

    Not sure how the SO example worked without this, but...it seems to be working for me now.

    Thanks for all the assistance on this.

  • How can I make a mock DB to be pulled into Alteryx?

    Unsolved
    2
    0 Votes
    2 Posts
    388 Views
    JonBJ

    @pavanforza
    Hello and welcome.

    Qt supports SQLite as a database, which is very simple to set up and use (file based). You can still send it SQL queries/statements to execute through the same Qt QSql...classes as would be used against an Oracle database.

  • Missing QT software access

    Moved Unsolved
    1
    1 Votes
    1 Posts
    283 Views
    No one has replied
  • QML: TabBar and StackLayout

    Solved
    9
    0 Votes
    9 Posts
    2k Views
    mzimmersM

    OK, I got it figured out. As @JoeCFD suggested, I needed anchors instead of Layout.*. Someday, I'll commit this to memory -- @fcarney will probably only have to remind me another 100 times...

    Thanks for the help.

  • getting QML to report on font used

    Solved
    4
    0 Votes
    4 Posts
    664 Views
    mzimmersM

    Since @JKSH answered my original question, I'm marking this as solved. I'll bring up my other questions in a new topic with a more accurate title.

  • lazily relocated series of X11 windows

    Solved
    2
    0 Votes
    2 Posts
    350 Views
    Kent-DorfmanK

    so no group feedback on this question but I did manage to locate (by accident) a utility that accomplishes the task.

    xdotool windowmove {windowid} {x} {y}

    uses XTEST extension which insers emulated mouse and keyboard events to the X server.

  • Porting a GUI from Qt 2(?)

    Unsolved
    6
    0 Votes
    6 Posts
    567 Views
    SGaistS

    Yes, that would the the correct sub-forum.