qlist

Qt之容器类

六月ゝ 毕业季﹏ 提交于 2019-12-16 20:32:01
Qt的顺序容器类:QList、QLinkedList、QVector、QStack和QQueue。 1、QList   以数组列表(array-list)形式实现,以下表索引方式对数据项进行访问。   对数据项的操作函数有:#include <QList>   insert()、replace()、removeAt()、move()、swap()、append()、prepend()、removeFirst()、removeLast()、at()、begin()、end()、clear()、erase()、count()、size()、length()、push_back()、push_front()、pop_back()、pop_front() 来源: https://www.cnblogs.com/guohao8786/p/10908832.html

Qt 下快速读写Excel指南

陌路散爱 提交于 2019-12-16 11:17:23
Qt Windows 下快速读写Excel指南 很多人搜如何读写excel都会看到用 QAxObject 来进行操作,很多人试了之后都会发现一个问题,就是慢,非常缓慢!因此很多人得出结论是 QAxObject 读写excel方法不可取,效率低。 后来我曾试过用ODBC等数据库类型的接口进行读写,遇到中文嗝屁不说,超大的excel还是会读取速度慢。 最后,看了一些开源的代码后发现,Windows下读取excel,还是用 QAxObject 最快!没错,就是用 QAxObject 读写最快!!!(读取10万单元格229ms) 大家以后读取excel时(win下),不用考虑别的方法,用 QAxObject 就行,速度杠杠的,慢是你操作有误!下面就说说如何能提高其读取效率。 读取excel慢的原因 这里不说如何打开或生成excel,着重说说如何快速读取excel。 网上搜到用Qt操作excel的方法,读取都是使用类似下面这种方法进行: QVariant ExcelBase :: read ( int row , int col ) { QVariant ret ; if ( this - > sheet != NULL && ! this - > sheet - > isNull ( ) ) { QAxObject * range = this - > sheet - >

How to convert QList<T> to QVariant?

妖精的绣舞 提交于 2019-12-13 16:13:34
问题 I can't find a way to convert my QList<T> to a QVariant . There's a constructor QVariant(const QList<QVariant> &val) , but no constructor for QList<T> , is it possible to convert directly a QList<T> ? 回答1: Example QList<int> ints{1,2,3}; QVariant var = QVariant::fromValue<QList<int>>(ints); 来源: https://stackoverflow.com/questions/44436386/how-to-convert-qlistt-to-qvariant

Iterating over a QVariant that is a QList<int>?

徘徊边缘 提交于 2019-12-13 05:07:11
问题 I'm using QObject's dynamic property to store information to be used in a Slot that can access said property. The sender is a QState with: myQState->setProperty("key", QList<int>(0, 1, 2)); I would like to convert the stored QVariant back to a QList so it can be iterated. The following code does not work (error C2440: QVariant can't be converted to QList with {[T=int]): QVariant vprop = obj->property("key"); QList<int> list = vprop; // < - - - - - - - - ERROR foreach (int e, list ) { qDebug()

Serialize a class with a Qlist of custom classes as member (using QDataStream)

给你一囗甜甜゛ 提交于 2019-12-13 04:25:06
问题 I'm trying to serialize class Lesson(my custom class[I removed some setters]), which includes a QList(Question is also my custom class). During test serialization I get a SIGSEGV(segmentation fault) when deserializing any object of QList inside the class Lesson. UPD1: I serialized QList* and now I changed it to QList, but SIGSEGV still appears. class Lesson { public: Lesson(); Lesson(QString, QString, QList<Question>); QString getName() const; QString getText() const; QList<Question>* getTest

loading data from database to expose in qml

北慕城南 提交于 2019-12-13 02:27:09
问题 I am new to QML, so please forgive my lack of knowledge. I am loading some data from my database - after clicking in a button - and I want to fill a ListView with it. This is my ListView: Rectangle { id:tblKules anchors.horizontalCenter: parent.horizontalCenter width: menuListaItem.width height:300 visible:false color: "#e5e6e8" ListView { id: listView anchors.fill: parent; anchors.margins: 5 model: mainController.listaDispositivos spacing: 1 delegate: Component { Rectangle { id:item width:

Removing items from a QList of pointers

只愿长相守 提交于 2019-12-12 04:55:35
问题 I have a QList of pointers to objects. QList <MyObj*> mylist; I add to the list as follows mylist.append(new MyObj(1)); mylist.append(new MyObj(2)); So far so good. So for exampple if I have a MyObj object and I want to search the list for a match how do I do it? The indexOf memeber funcion requires that I have the comparison operator for MyObj, but MyObj does not have one. So given a MyObj object, what is the best way to see if it is contained in the list? Regards 来源: https://stackoverflow

QList和QVector的一些基本用法

Deadly 提交于 2019-12-11 17:03:07
QList和QVector基本用法一样 QList<T> list 和QList<T*>list T可以是数据类型或者指针(类指针) 定义一个数据结构体 typedef struct student { int id ; QString name ; QString sex ; int age ; QString des ; } student ; 或者定义一个类 class Facility : public QObject { Q_OBJECT public : explicit Facility ( QObject *parent = nullptr ); QString name ; signals : public slots : } 1、创建QList (1)T为非指针的数据结构 QList < student > SList ; // 非指针 for ( int i = 0 ; i < 10 ; i ++) { student s1 ; s1 . id = i ; s1 . name = " 哇哈哈" + tr ( "%1" ). arg ( i ); s1 . age = 10 + i ; SList . append ( s1 ); } (2) T为指针类型 QList < Facility *> flist ; Facility * P = new

Using the operator<< with a QStringList pointer

风流意气都作罢 提交于 2019-12-11 03:37:51
问题 How I can change this code? QString s="123"; QStringList *myList=new QStringList; myList<<s; Error: no match for 'operator<<' (operand types are 'QStringList*' and 'QString') *myList<<s; does not work too: myList is Empty, after this. 回答1: There is little to no point in using a pointer for a QStringList because this is an implicitly shared class due to the copy-on-write. You can find further details for that below: http://qt-project.org/doc/qt-5.1/qtcore/implicit-sharing.html Which means, I

Using QImage With QQuickImageProvider

♀尐吖头ヾ 提交于 2019-12-11 03:31:47
问题 I have created a class that inherits QQuickImageProvider Class, but i want to use the requestImage() function of QQuickImageProvider to set the QImage variable , but i dont know how to do that as i need that QImage variable from a class object , which has been deifned in QML from ContextProperty and want to use the id variable as an index values to retrieve QImage from a List. Here is the main function code: int main(int argc, char *argv[]) { QApplication app(argc, argv); ImageProvider