Skip to content
QtWS25 Call for Papers
  • 0 Votes
    8 Posts
    858 Views
    F

    @ChrisW67 What if I want to resize the tabs but index-based?

    Similar to a web browser, I want to enable a button/tab-like interface. The first tab should, if possible, display only the icon and the last being a new tab option will display a varied interface.

  • 0 Votes
    8 Posts
    2k Views
    JonBJ

    @b2soft

    I want to customize BrowserModel ::data() returning colors using QSS

    @raven-worx knows much more than I, but I don't get this. role == Qt::TextColorRole will want to return a QBrush (http://doc.qt.io/qt-5/qt.html#ItemDataRole-enum). How is that linked to returning a string to use for a name in a stylesheet? :confused:

  • 0 Votes
    5 Posts
    2k Views
    M

    @mrjj okay thank you very much! And yes, my Designer also have a StyleSheet editor like this:

    0_1528759090155_style.PNG

    Cheers

  • 0 Votes
    2 Posts
    965 Views
    S

    I fixed the issue by dropping the source string from the .metainfo files.

    For anyone that cares I was following these instructions: http://doc.qt.io/qtcreator/creator-qml-modules-with-plugins.html and on step 5 I picked a random metainfo file when I searched the Qt folder for .metainfo, not the one they specifically chose (qtcharts.metainfo vs qtquickcontrols2.metainfo)

    The qtcharts one was probably for some other type of module use where specifying the source does something I don't need, the qtquickcontrols2 ended up having the syntax I really wanted in the end. Eventually I found this example and found out dropping the source worked: https://forum.qt.io/topic/56207/how-to-load-custom-qml-controls-into-the-qml-designer

  • Tomtom linux

    Moved Unsolved Brainstorm
    5
    0 Votes
    5 Posts
    2k Views
    aha_1980A

    @GhostWolf said in Tomtom linux:

    The reason I wanted the TomTom was because I just have it laying here, and the programm doesn't have to be fast. The only thing it needs to do is to send data if I press a button on the screen.

    As @Wieland already said, most likely nobody here can help you with this. So even if it's possible (from hardware side) to do what you want, you're on your own.

  • 0 Votes
    3 Posts
    1k Views
    R

    @Wieland
    I will try as soon as I find the time :)

  • 0 Votes
    7 Posts
    6k Views
    6

    @raven-worx

    You're correct. I am now inserting a nullptr in the insertRows() function, and then later in setData I use the QList::replace() function to actually put a shape into that index.

    The reason it didn't work is that I used the pre-compiled Qt binaries. On the binaries, for some reason (probably that I don't know how to set it up properly), putting a breakpoint on any function that is defined in the source code does not trigger the debugger to stop there at all.
    I fixed that by deleting Qt, compiling it from the sources (with some headache), installing Qt Creator again and pointing it to the kit. Now I can put breakpoints into the source code and the debugger will actually stop on them, revealing that the call to setData actually does happen when dropping rows.

    After all this I came upon a solution that seems to work, I'd just like an opinion if this is a good way to go about it, it might need some polish.

    I figured I didn't want to reimplement the whole drag and drop system just to be able to pass some indexes through it, when I am already displaying the shape's names in the view, so I thought... to determine the index, I can just iterate through my list and find the shape that has the same name as the one that I clicked on. Here's what I do in setData:

    bool ShapeListModel::setData(const QModelIndex& index, const QVariant& value, int role) { //This role is used when double-clicking on an item if (index.isValid() && role == Qt::EditRole) { if (value.toString() != shapeList.at(index.row())->getName() && !value.toString().isEmpty()) { shapeList[index.row()]->setName(value.toString()); emit dataChanged(index, index); return true; } } //And this one when drag and dropping else if (role == Qt::DisplayRole) { Shape* shape {nullptr}; for (int i = 0; i < shapeList.size(); i++) { if (i == index.row()) { //do nothing } else { if (shapeList.at(i)->getName() == value.toString()) { shape = shapeList.at(i); if (shape) { shapeList.replace(index.row(), shape); return true; } } } } } return false; }

    So basically, I do a for loop on my shapeList to find the shape which has the name displayed in the QVariant "value" (the name that I clicked on in the view). Once I found it, I set a pointer to its address. Then I simply replace the contents of the empty row (the one with the nullptr) with the shape that I clicked on. Afterwards the call to removeRows takes care of the shape's original index. This works fine. The only requirement is that each shape has a unique name, which is probably a good idea to do anyways. The only thing I'm not sure about is the "else if (role == Qt::DisplayRole)", but according to the debugger that is the set role when drag and dropping.

    What do you think of this implementation?

  • 0 Votes
    14 Posts
    8k Views
    N

    Alright, promoting from QWidget indeed did the job and now it works well!
    Thanks for the both of you.

  • 0 Votes
    5 Posts
    3k Views
    Arty.McLabinA

    @mcosta

    i am able to view the page inside the browser tho, why can't Qt read it then?

  • 0 Votes
    6 Posts
    4k Views
    S

    @p3c0
    you are right it's better to use custom delegates like you say.
    I am not sure my solution runs with QListWidget but it is ok too with QTablewidget.

  • 0 Votes
    20 Posts
    13k Views
    SGaistS

    Good !

    However, I'm not sure I'm following you on that one. Where did you put that resize ?

    If you can't from the Topic Tools menu, then just edit the thread title and prepend [solved]

  • 0 Votes
    2 Posts
    1k Views
    ?

    Hi,
    I don't think it's possible. IMHO the easiest way to achieve this is to print to a temporary PDF file and then call lp with the needed options by yourself.
    Cheers!