跳到內容

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.1k 主題 77.8k 貼文
  • Q_INVOKABLE funciton returning null when called in QML 'onDestruction'

    Solved
    5
    0 評價
    5 貼文
    1k 瀏覽
    jeremy_kJ
    @Circuits said in Q_INVOKABLE funciton returning null when called in QML 'onDestruction': Is there a way to test if the object itself is null from the QML? The test is the same as for any variable. if (! obj) tests for null or undefined. Using an explicit !== null also works. Presumably the object in this case is this, but getting into the situation where this === null is something you probably want to avoid. I have a workaround. I created two states: open, closed and a property: property string prevState: "" whenever the state changes I set the previous state to be the current state that way I can identify when the state is changing from open to closed and in that instance I can call the methods. However, while this works it doesn't explain how to deal with the QMl calling an object which is null. Without code, I can't suggest anything better than if (this) { do_something(); }, which looks like a work around for a deeper problem.
  • QML QDoc grouping property into one explanation

    Unsolved qdoc qml qt quick group propertie
    4
    0 評價
    4 貼文
    883 瀏覽
    T
    Still looking for a solution
  • Calling C++ slot from Qml signal

    Solved
    5
    0 評價
    5 貼文
    3k 瀏覽
    A
    Hey @sierdzio, @sierdzio said in Calling C++ slot from Qml signal: So you are using QQmlEngine? It was not in your original snippet so I didn't use it either. Because I didn't have any idea that we can have a QML project without using the QML engine (I've just created the QML project with QtCreator). In such case, you can instantiate the C++ class in QML if you register it first with qmlRegisterType > methods. It's a more advanced technique so I didn't mention it before. There are also a few other > ways to achieve this. But in general don't worry about root context properties - they work fast and > are easy to set up. And Qt Creator's code model understands them well, too. Ok I'll go with the root context property for now and I'll keep in my mind the qmlRegisterType. Thank you very much for your answers!
  • TabBar : Modify the TabButton Mouse Area

    Unsolved
    1
    0 評價
    1 貼文
    201 瀏覽
    尚無回覆
  • How to connect to a device via on bluetooth by using QML?

    Unsolved
    1
    0 評價
    1 貼文
    458 瀏覽
    尚無回覆
  • Missing Sort Indicators for Table Columns

    Unsolved qml tableview
    1
    0 評價
    1 貼文
    431 瀏覽
    尚無回覆
  • Open specific Folder in FileDialog

    Unsolved
    3
    0 評價
    3 貼文
    518 瀏覽
    J
    @IntruderExcluder Thanks for your reply. Actually I am just using the pictures folder to open a Json file which I stored there before. I used the pictures folder because it's one of the standart paths which are writable. So my goal is selecting a specific folder. But I did not know that I can start Activities or Intents from c++. So if I manage to achieve it with native Android, can I just include the Activity in the code? Edit: Related to this stackoverflow answer there is no Intent which opens a particular folder in android. https://stackoverflow.com/questions/68224141/how-do-i-open-a-file-picker-at-the-applications-files-directory
  • how to access properties in a delegate

    Unsolved qt 5.7 qml delegate qt quick
    4
    0 評價
    4 貼文
    967 瀏覽
    B
    @vinaygopal "what if i want to access the visibility or a property i have defined in the delegate?" There are multiple instances of your delegate, corresponding to the part of the model being displayed. Which instance do you want the property from? If it's a common property that is not specific to a single instance, then the same answer applies - factor it out to the table level and use it in the delegate. If it is a property specific to a delegate instance you are interested in, how do you specify which delegate? Does the data actually belong to the model? What is it that you are trying to achieve?
  • QtQuickControls FileDialog Automation

    Unsolved
    1
    0 評價
    1 貼文
    224 瀏覽
    尚無回覆
  • 此主題已被刪除!

    Unsolved
    1
    0 評價
    1 貼文
    22 瀏覽
    尚無回覆
  • Sort by Clicking on Column Headers in QML TableView

    Unsolved qml qtableview c++
    1
    0 評價
    1 貼文
    727 瀏覽
    尚無回覆
  • Can I do this Animation in Qt

    Unsolved
    10
    0 評價
    10 貼文
    902 瀏覽
    ?
    @haiku Nice, thanks for sharing.
  • QML ListView and ListElement - initialization that is actually of use

    Unsolved
    3
    0 評價
    3 貼文
    1k 瀏覽
    B
    @VFCraig If I have understood correctly, an aspect of each delegate component in your list view is to show the current date and time. As you yourself allude to, the "current time" is a system-wide thing and I can't really see any benefit in trying to do this via the model. I would suggest that a better way to think about is that your delegate makes use of a visual component that displays the current date and time and that this is independent from the parts of the delegate that genuinely depend on the model (i.e. the data that is specific to the current item in the list).
  • Show column titles in HorizontalHeaderView

    Unsolved
    4
    0 評價
    4 貼文
    2k 瀏覽
    fcarneyF
    The docs don't show it specifying a model. Not sure what is supposed to happen with headerData. I don't know how to build the delegate for a qabstracttablemodel. I just read the docs and figure things out. Edit: This might help. https://stackoverflow.com/questions/63719365/horizontalheaderview-not-calling-headerdata-of-qabstracttablemodels-child
  • Adding a "ui" to an empty Project template

    Solved
    2
    0 評價
    2 貼文
    291 瀏覽
    D
    It seems that this is some sort of GUI Issue under Qt6 with linux. I reinstalled QtCreator and used Qt 5.12 and now when i switch to the Designer in an empty project i can see a "canvas" and put components on it. So its solved for me.
  • CPU usage spike in qml charts

    Unsolved
    1
    0 評價
    1 貼文
    173 瀏覽
    尚無回覆
  • QML ListModel: remove: indices out of range

    4
    0 評價
    4 貼文
    1k 瀏覽
    B
    If the requirement is, as you say, simply to output the selections, the simplest way might be to clear the output list and rebuild it every time a selection is changed. Then you just need to loop over the combo list and add the items that are selected. I have noticed that you are not storing the check state in your combo model. You would need to do this to implement what I just suggested, but in any case I think you can't rely on the delegate to store the checked state. You might get away with it here, but in general, and especially if you had a longer list in your combo, delegates can get "recycled" in the view so you cannot rely on them holding any state.
  • Proper access of buttons from ButtonGroup?

    Solved
    2
    0 評價
    2 貼文
    430 瀏覽
    eyllanescE
    @robro Use ButtonGroup { id: btnGroup onClicked: function(button) { console.log("clicked:", button.text); } }
  • ListView, ListModel and ListElement and trying very hard not to hard code, which would make it worthless

    Unsolved
    5
    0 評價
    5 貼文
    547 瀏覽
    B
    @VFCraig Ok, I see what you are saying, but you have a very specific use case there, where your delegates simply create a button. It's not unusual in ListView instances to define more complex delegates with two or more items in some sort of layout. In such cases, there isn't such a simple initialisation as each delegate item will pick out whatever model data it needs. Additionally, it is not unusual not to bind the data directly to delegate properties but instead to bind to expressions involving the model data.
  • Qt Quick Emulation Layer Crashed

    Unsolved
    1
    0 評價
    1 貼文
    173 瀏覽
    尚無回覆