Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. Tags
    3. qlist
    Log in to post

    • SOLVED Retrieving a stored QSqlResult throws an access violation error.
      General and Desktop • qlist qsql qsqlrecord • • mmassaro  

      5
      0
      Votes
      5
      Posts
      35
      Views

      Unless you have some hardcore use case, perhaps you don't need to cache at all? SQLite is pretty fast, and Qt comes with QSqlQueryModel / TableModel helper classes. In my (limited :D) experience, it works really well and fast, even on slow hardware.
    • SOLVED QList<QObject*> testList, how to access individual QObject.at() values?
      General and Desktop • qml qobject qlist qdebug • • BoGut  

      11
      0
      Votes
      11
      Posts
      76
      Views

      So it looks like I was missing the variable statement after this. It works now. Thanks everyone for the help. QList<QObject*> list() const; for (int index=0; index < list.size(); index++) { QObject *test01 = list.value(0)->name(); qDebug() << test01; }
    • SOLVED List of key-value pairs that can return both keys and values
      General and Desktop • qlist qbluetooth containers • • SpaceToon  

      14
      0
      Votes
      14
      Posts
      125
      Views

      @SpaceToon I might worry at 20,000, but not at 20 :)
    • SOLVED which container (Qvector or QList) is good to use for insert, delete, and access the last element.
      General and Desktop • c++ qlist qvector datastructures • • Yash001  

      5
      0
      Votes
      5
      Posts
      155
      Views

      @Yash001 said in which container (Qvector or QList) is good to use for insert, delete, and access the last element.: I am adding data point at last position of container, and only accessing the last element of container. So which is better container? It's what we call Last In First Out ( LIFO) queue. So QStack seems an obvious candidate. QStack inherits from QVector.
    • SOLVED Create slideshow in qt creator
      Mobile and Embedded • qlist qtcreator 5.11 • • RAJ Dalsaniya  

      20
      0
      Votes
      20
      Posts
      654
      Views

      @RAJ-Dalsaniya Super to hear \o/ Please mark as solved using the Topic Tool button at first post :)
    • SOLVED Why does the const Object returned by QList::at() block access to instance methods?
      General and Desktop • c++ qlist class object const • • oblivioncth  

      8
      0
      Votes
      8
      Posts
      562
      Views

      @oblivioncth said in Why does the const Object returned by QList::at() block access to instance methods?: Hey, going above and beyond! Thanks again. You're most welcome! I'm not completely ignorant in the ways of C++ though, I'm not 100% certain, but fairly confident that: Const 1) Ensures the returned value can't be modified, Yep. the use cases of which I'll admit I'm not really privy to. Use case 1: Allow the caller to read the data without creating a copy, AND Make sure the data is read-only If the returned reference is non-const, the caller will be able to directly modify the object's internal memory. This breaks encapsulation. Use case 2: Allow the function to be called in another const function. There's a const and a non-const version of QList::operator[](int): T & operator[](int i) const T & operator[](int i) const Version #1 allows the caller to modify the QList element. However, it cannot be called in a const function -- it will cause the error in your original post. Thus, version #2 is required for use in const functions. I know that its only really useful when dealing with user defined classes and returning by value reference (which is the case in your example) to prevent memory modification if desired. (Acknowledging your typo) Why would it be "only really useful when dealing with user defined classes"? Notice that QList::at() returns a const reference. I do remember seeing something about this being somewhat obsolete in C++ 11 (or was it 17) and forward, though I'm not sure why. Returning const references is defintiely not obsolete. You might be remembering move semantics, which is said to make passing parameters by const-reference obsolete: https://stackoverflow.com/questions/10231349/are-the-days-of-passing-const-stdstring-as-a-parameter-over Qt will not be making this change anytime soon though; this is too disruptive. Const 2) The pointer argument "arg" in that class is for the type "const MyOtherClass", i.e. a pointer to a constant value (value cannot) Yep, myfunc() cannot modify the MyOtherClass object. (In other words, it can only call const methods of the object) Const 3) Marks the pointer "arg" itself as pointer, so that the pointer itself also cannot be modified) Yep. This is not very useful IMHO, but it's part of the language. Const 4) Thanks to you, I now understand this means that the function does not modify the object instance that the function is being called on/from (i.e. cannot manipulate member variables). Great! Next, start thinking about the difference between logical const-ness and physical const-ness: https://isocpp.org/wiki/faq/const-correctness#logical-vs-physical-state Btw I do like a lot of the explanations on that site as they provide a lot of detail and examples, and I had never read the article for const. Agreed
    • SOLVED QTableView, QStandardItemModel and underlying data in a QList
      General and Desktop • qtableview qlist qstandarditem objects underlyingdata • • Gerhard_Old  

      7
      0
      Votes
      7
      Posts
      1406
      Views

      Hi! Thank you very much for your help. I thought and I want to make little steps at first, so I changed my struct: // person.h struct person { int id; QStandardItem* name; QStandardItem* family; } Now I can directly use my members and append them. I do not need write access, but to show my objects directly in QAbstractTableModel is indeed a sexy idea. I am trying around with QModelIndex, club_model->item(), club_model->itemData() and roles, and when I am done with that, maybe I'll try my own model. For now, my question is solved! Regards Gerhard
    • UNSOLVED runtime error terminate called after throwing an instance of 'std::bad_alloc'
      General and Desktop • qt creator qlist qstringlist runtime error • • Lasith  

      8
      0
      Votes
      8
      Posts
      5011
      Views

      @Lasith well std::bad_alloc often comes when out of memory. My guess is that <List1[0].size() is always true since you add to it for each loop and hence create an infinite loop. Did you try VRonin code? Update: If you just want list1 in [0] and list2 in[1] why all the loops then?
    • UNSOLVED Increasing QList<QStringList> contents twice!
      General and Desktop • qlist qstringlist loop • • Kushan  

      12
      0
      Votes
      12
      Posts
      2476
      Views

      @kshegunov said in increasing QList<QStringList> contents twice!: if it looks like a duck, swims like a duck, and quacks like a duck Slight thread derail, but I would say the op's question general is answered .
    • SOLVED Cannot add more than one struct onto a qlist within foreach loop
      General and Desktop • qlist loop struct • • CybeX  

      10
      0
      Votes
      10
      Posts
      2507
      Views

      @VRonin a suggest read is a SO post As mentioned earlier aswel, I will use this iterator (first time :p) Thanks for all the help!
    • SOLVED Save QList<QStringList> using QSettings?
      General and Desktop • qlist qsettings qt 5.7.0 • • qDebug  

      4
      0
      Votes
      4
      Posts
      5545
      Views

      I just had a typo in the group ^^ Sorry!
    • UNSOLVED How to assign the Qlist as model for ListView?
      General and Desktop • listview model qlist • • Mathan M  

      3
      0
      Votes
      3
      Posts
      1630
      Views

      The easy way: get rid of PortalMapItemInfo, store the values in 4 different QStringList and use a QStringListModel The proper way: in HomeController.h add Q_DECLARE_METATYPE(PortalMapItemInfo) http://doc.qt.io/qt-5/qmetatype.html#Q_DECLARE_METATYPE Instead of a List store your data in a 1-column QStandardItemModel and expose it via a Q_PRPERTY
    • UNSOLVED Qlist returns Size as -1
      General and Desktop • qml qlist esri • • Mathan M  

      11
      0
      Votes
      11
      Posts
      2000
      Views

      @Mathan-M Ok, then have a look at my code above; that works as expected, what's different to your code?
    • SOLVED How to append struct to QList?
      General and Desktop • qlist struct append • • pauledd  

      13
      1
      Votes
      13
      Posts
      9522
      Views

      Thank you for the hints, I think I now have enough information to solve it.
    • SOLVED ASSERT failure in QList<T>::at: "index out of range"
      General and Desktop • c++ qt 5.7 qlist qstringlist qurl • • Qjay  

      24
      0
      Votes
      24
      Posts
      17457
      Views

      I too was also thinking of full rewrite but i don't have much time for that right now :/ .
    • SOLVED QtConcurrent::run and QList<QListWidgetItem*>::Iterator crashes
      General and Desktop • qlist qtconcurrent iterators • • Max13  

      6
      0
      Votes
      6
      Posts
      1679
      Views

      @kshegunov said: You're missing the fact that QWidget and its descendants aren't reentrant. Actually, I missed more than that... I completely miss the fact that, when dealing with QWidget or simillar + threads, that exactely when I should have used signal/slot mechanism... I feel dumb about it, but anyway, the Crawler object now crawls using Qt::Concurrent and send a signal with the text to add to the QListWidget, and then a MainWidget's slot is called to create and add the item. Thanks for your help
    • UNSOLVED Setting QList properties in qss files
      General and Desktop • qlist qss qproperty • • mongrelmac  

      5
      0
      Votes
      5
      Posts
      1633
      Views

      I see. Thanks @raven-worx @SGaist!
    • UNSOLVED Problem with Qlist and QMessangeLogger
      General and Desktop • qlist qmessangelogger • • lorow23  

      3
      0
      Votes
      3
      Posts
      1896
      Views

      @Chris-Kawa Sorry for getting you into a mistake and for leaving my problem without any further explanation. So, the variable intArray is just a simple Qlist, i forgot to change its name before posting so please, excuse me for that. For index, it looks like index = w * 4, and after that, there is value = qRgba(intArray[index-3], intArray[index-2], intArray[index-1],intArray[index]); I know that if the length of my text is not divisible, it's not gonna work. And here the Qlist come in handy. I can check if this number is divisible by 4 and if yes, the code goes as it is now, but when it's not I wanted to add as many items equal to 0 as I need to make it divisible. Does my explanation makes any sense? I will try try to explain it like that : if (number is divisible by 4) { here comes my algorithm for making this image } else { add as many number as it is needed to make it divisable to qlist and then run the algorithm } But then those error appeared and I don't really know how can I get rid of them :/ But, how could I make it with vectors? Would it be faster or safer than by using Qlist? Thanks a lot for help!
    • SOLVED QList index
      General and Desktop • qlist index • • Walux  

      16
      0
      Votes
      16
      Posts
      4542
      Views

      @Chris-Kawa Got it ;)
    • SOLVED DBus reply data accessed via QString
      General and Desktop • qstring qlist qvariant dbus method • • amonR2  

      22
      0
      Votes
      22
      Posts
      7412
      Views

      @micland WOOW!!! Thank you sooo much micland!! It works!!! I tried a code similar to yours but some data were missing. Just needed to do a very tiny modification on your code: qDebug() << key << value.variant().toString(); or directly qDebug() << value.variant().toString(); Except it, it is perfect! Thank you again. @micland said: I have no clue why the qdbusviewer of Qt 5.6 is unable to call the DBus method but the code snippet above is working fine. I hope it is going to change as I intend to use it or the 5.7 version very soon. Cheers again.
    • SOLVED QList<QObject*> and Memory Leak Issue
      General and Desktop • qobject qlist memory leak pointer • • Dong  

      15
      0
      Votes
      15
      Posts
      10924
      Views

      @kshegunov There is a reason why I can't use QT Property Binding (It only support predefined Property using Q_PROPERTY script). Please take a look at my topic about Auto Binding 2 ways with Dynamic Property But Binding is an other topic. About "Object's pointers & Memory" I also take an advise from a Pro in C++ & memory management. His solution is implement a Factory Pattern to Create/Delete Object's pointers (also free memory when an instance had no pointer to it.) (I think I'll give it a try)
    • SOLVED How to add an item to a QList inside a QMap?
      General and Desktop • qlist qmap • • Ferni  

      5
      0
      Votes
      5
      Posts
      4909
      Views

      I'm such a newbie programmer :( I study electronics engineer and I like programming but I don't receive a good foundation in my university and I had to learn a lots of things by myself. Also, I haven't done any OOP for years and I'm new in Qt. Many many thanks!! I will pay more attention to my coding :)
    • SOLVED C++ Multi-Client TCP Server with QList
      General and Desktop • signal & slot qlist tcp tcpsocket tcp server • • Hannes T  

      3
      0
      Votes
      3
      Posts
      2156
      Views

      @mrjj Thank you a lot, it works!!!
    • SOLVED Clean QList for QMLListProperty
      General and Desktop • qlist delete clear qdeleteall qmllistproperty • • Alart  

      3
      0
      Votes
      3
      Posts
      1704
      Views

      However I did certainly what you said that was only little part. Thank for your answer, without it I would only find a way around this issue probably. (like 2 parallel QLists) So what works? I make additional QObject with parent "this (list of lists)". Then I make it parent of every QObject I want to delete (QObjects with list and QObjects within lists). I don't change CppOwnership. After that I clear() list and add new QObjects (obsolete QObjects stay accessible as children of that additional QObject). After final emit I delete that QObject with deleteLater(). QPointer isn't necessary here I think. I tried deleteLater in another way of doing things and it crashed, so that is the only way I found. My application deletes QObject and all children with it. With neither crash or leak. QObject * delQObject = new QObject (this); set_parents_list(delQObject ); m_list_of_listQobjects.clear(); for () m_list_of_listQobjects.append(new listQobject); emit m_list_of_listQobjectsChanged(m_list_of_listQobjects()); delQObject->deleteLater(); where: listoflistsofQObjects :: set_parents_list(QObject * parent) { for (int i = m_list_of_listQobjects.count(); i>0; i--) { m_list_of_listQobjects[i-1]->setParent(parent); m_list_of_listQobjects[i-1]->set_parents_list(parent); } } Following function isn't necessary if QObjects already have parent that is deleted (like listofQObjects or some QObject inside it). It's safer to make elements children, because then one doesn't need to call deletes in destructor. listofQObjects :: set_parents_list(QObject * parent) { for (int i = m_list_ofQobjects.count(); i>0; i--) { m_list_ofQobjects[i-1]->setParent(parent); } } I don't know if is it "right way", I even found here somebody uses my earlier version with additional list (but it's unsafe for sure). The best explanation how to manage memory in qt I found here. If there is better way to do so, please share.
    • SOLVED Problem with QList
      General and Desktop • qlist qstringlist • • shahriar25  

      5
      0
      Votes
      5
      Posts
      1650
      Views

      Hi, There's usually no need to allocate QList nor QStringList on the heap. Do you have any reasons to do that ?
    • UNSOLVED QListView to display created Shapes
      General and Desktop • qlistview qlist • • 6ort  

      7
      0
      Votes
      7
      Posts
      2184
      Views

      When using a custom model, the usage is to add specialized methods to your model to add/remove your custom objects. So when you add/remove a Shape you know exactly where they are so you can use beginInsertRow/endInsertRow and the update will happen automatically for you.
    • Array or list for drawing multiple shapes
      General and Desktop • qlist qpaintevent • • 6ort  

      6
      0
      Votes
      6
      Posts
      2488
      Views

      Rather than going up-front with building your own GUI for a painting program, I'd recommend taking a look at what is currently existing like Krita or KolourPaint. Painting is a vast subject that can cover many aspects. Just take a look at Qt's examples on the subject. You should also take the time to look at QtQuick for the GUI design part.
    • [Solved]QList of QScopedPointers
      General and Desktop • qlist qscopedpointer smart pointer • • Joel Bodenmann  

      8
      0
      Votes
      8
      Posts
      3424
      Views

      @Asperamanca I am actually not sure anymore. I thought that there was an issue regarding the boundingRect() implementation but I have changed my design since then. I will give this another thought.
    • Qlist in Qtreeview
      General and Desktop • qlistview qlist • • Gillou_beginqt  

      4
      0
      Votes
      4
      Posts
      1459
      Views

      Well, your model should then return one column and the string list size as row count. Then data should return the appropriate string from the list
    • [SOLVED] QList's append and prepend SEGFAULTs
      General and Desktop • qlist qtcore • • Peppy  

      3
      0
      Votes
      3
      Posts
      2455
      Views

      It's been solved. "this" pointer was null, thus it was crazy debugging.
    • QList of QWidgets not painting
      General and Desktop • qwidget qlist paint paintevent painting • • Maxim DC  

      2
      0
      Votes
      2
      Posts
      915
      Views

      Hi, Do you mean move them at the right position ?
    • Getting instances of QList<T> for a QQmlListProperty
      General and Desktop • qml qlist subclassing qqmllistpropert • • Maxim DC  

      1
      0
      Votes
      1
      Posts
      535
      Views

      No one has replied

    • [SOLVED] Qt Fatal Segmentation Fault when accessing QList from qml
      General and Desktop • qml qlist qmap segmentation fa • • Maxim DC  

      3
      0
      Votes
      3
      Posts
      1188
      Views

      Hi, Something's not clear with your code, you return a QQmlListProperty<MyObject> while mMyObjectsList is a QQmlListProperty<MyObject*>. Also why are you calling (&mMyObjects)->values(); and not mMyObjects.values();?
    • Exposing a QMap to qml
      General and Desktop • qml qt creator qlist qmap • • Maxim DC  

      1
      0
      Votes
      1
      Posts
      741
      Views

      No one has replied

    • QList and QPoints error: passing 'const QPointF' as 'this' argument of 'qreal& QPointF::rx()' discards qualifiers
      General and Desktop • error qlist qpoint error passing c • • metty  

      4
      0
      Votes
      4
      Posts
      2346
      Views

      super, thank you! that solved my litttle problem.
    • Qt5.3.2 QList losing QString contents between assignment and use
      General and Desktop • qlist ubuntu 14.04 qt 5.3.2 data loss deep copy • • Jeff Andle  

      4
      0
      Votes
      4
      Posts
      1267
      Views

      @Jeff-Andle If you do not like that cleanup or if it is too hard to decide whether to free the memory you can use one oft these. QSharedData QSharedDataPointer QSharedPointer I have used QSharedDataPointer (but not the others so far), and it seems to work nice.
    • Set color for each index in a Qlist of type color
      General and Desktop • qlist qcolor • • Ratzz  

      7
      0
      Votes
      7
      Posts
      2856
      Views

      @Chris-Kawa Thanks for the reply I messed up as you mentioned above . I used your code to make it work. thank you ;) QList<QColor> colors = { QColor::fromRgb(0,102,104,255), QColor::fromRgb(102,102,104,255), QColor::fromRgb(0,0,104,255) }; for(int i = 0; i < colors.size(); ++i) combo->setItemData(i, colors[i], Qt::BackgroundRole);
    • [SOLVED] Strange Sigsev On QSqlQuery.exec();
      General and Desktop • qlist qsqlquery qt 5.4.2 qt 5.3.2 • • Brochadinho  

      9
      0
      Votes
      9
      Posts
      2510
      Views

      at funtion gerarRelatorio i swap the qDeleteAll on line down(original position). and it worked. qDebug()<<"Documentos processados para a Tabela de Relatorio"; acessodb::setDataUltimoRelatorio(idEmpresa,idCliente); qDeleteAll(listaDocumentos); listaDocumentos.clear(); delete modelo; return true; I now will upload to my test server, and see what happens. i doesn't care any more about what is causing the problem, i just hope that is solved.
    • [SOLVED] QList<customObcject> saved with QSettings
      General and Desktop • qlist qsettings qdeclaremetatyp • • Michal  

      7
      0
      Votes
      7
      Posts
      2513
      Views

      error: invalid application of 'sizeof' to incomplete type 'QStaticAssertFailure<false>' enum {Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, __COUNTER__) = sizeof(QStaticAssertFailure<!!(Condition)>)} I have just read that: Values of a registered type can be constructed dynamically via QMetaType::construct() There is an example in the link above. Thanks for your help! I will figure it out, still missing pure c++ knowledge ;)