PDA

View Full Version : QTableWidget problem



MarkoSan
12th March 2008, 02:44
Hi to all!

I need to develop an subclassed table widget, which will look something like that:
+===================================+
+ Coca Cola +
+ 1,50 EUR 002 3,00 EUR +
+ Sprite +
+ 1,30 EUR 010 13,00 EUR +
+ Cheeseburger with salad +
+ 3,80 EUR 004 15,20 EUR +
+ Beefstake with potato and salad +
+ 24,67 EUR 012 296,04 EUR +
+===================================+
+ TOTAL: 327,24 EUR +
+===================================+The point is that every row consists of two lines, the upper one will hold merchandize name (solo column) and the lower one will consists of following fields in order:
price/merchandize unit (eur formatted, including euro sign
number of merchandize unit (formatted with leading 0)
price/unit*number of merchandize units (eur formatted, including euro sign)
at the end there will be total field
Does someone has any idea how to achieve that?!

wysota
12th March 2008, 09:02
Have you already tried anything?

MarkoSan
12th March 2008, 09:20
No, I need a few hints how to make two lines in a cell. Then I will begin.

wysota
12th March 2008, 09:49
Add a newline character to the string displayed.

MarkoSan
12th March 2008, 12:28
Ok, I am not total idiot. I need a cell, which is constructed from:

upper string line
and lower line, which is constructed from
price/unit string line and eur icon - left formatted
quantity string line (with leading zeros)
price/unit*quantity string line and eur icon - right formattedI cannot solve this with newline character.

aamer4yu
12th March 2008, 12:55
Well, why cant u have the brand name as column ? why need it as row ??

I am not sure of this will work... but hers my idea..
U can use delegates to have each cell as a widget. This widget has two rows... first the name, second the pprice, quantity etc.

hope it helps :)

MarkoSan
12th March 2008, 13:00
I am limited with table's width, it is critical to minimize table's width because the neighbour widget must take the largest size possible because of data representation.

jpn
12th March 2008, 13:11
So, what prevents you from using multiple columns? You'll get nice alignment out of the box. Besides, I'd use tree view instead of table view.

THRESHE
12th March 2008, 13:11
You can create a layout on a widget wich has the strings that you said and icons and then set this widget as a cell widget. Though it can be slow...

The other way is to implement a delegate and draw your cell there :)

MarkoSan
12th March 2008, 13:20
So, what prevents you from using multiple columns? You'll get nice alignment out of the box. Besides, I'd use tree view instead of table view.

Tree view is clumsy for touch screen user interaction. I've tried it before and because of fu... users I had to recode tree view into representation I want to do now in Qt. The same solution worked in Clarion for Windows.


You can create a layout on a widget wich has the strings that you said and icons and then set this widget as a cell widget. Though it can be slow...

The other way is to implement a delegate and draw your cell there :)

So. thanks for guideline, I will get to read docs about delegates ASAP.

MarkoSan
8th April 2008, 08:10
Well, now I have developec merchandize order class. What do I need to do to get the requested form in delegate? Reimplement the paintEvent()?? Or what?

MarkoSan
9th April 2008, 12:17
Well, I am slowly managing to get somewhere with my problem. Now, how do I translate the table cell (which has QString, qreal, qint16 and another qreal) from the first post into QVariant type? And how do I transfrom this cell into single QString?

wysota
9th April 2008, 13:50
If you use QTableWidget then you have to iterate all the cells and translate them manually. With a model based approach you could embed that functionality in the model.

MarkoSan
9th April 2008, 14:04
I've taken a look at Pixelator example and built my own model based on ImageModel class. Now, how do I embedd this functionality into my class, which code is:
#ifndef CSHOPPINGCARTMODEL_H_
#define CSHOPPINGCARTMODEL_H_

// qt includes
#include <QAbstractTableModel>
#include <QList>
#include <QString>
#include <QSize>

// custom includes
//#include "CMerchandizeOrder.h"
//#include "globals.h"

typedef struct
{
qint16 iMerchandizeID;
QString strMerchandizeName;
qreal rMerchandizePrice;
qint16 iMerchandizeQuantity;
qreal rSubtotal;
} structOrder;

typedef QList<structOrder> structOrders;

class CShoppingCartModel : public QAbstractTableModel
{
Q_OBJECT

public:
CShoppingCartModel(QObject* parent=0);
void setData(const structOrders& merchandizeOrders);

int rowCount(const QModelIndex& parent=QModelIndex()) const;
int columnCount(const QModelIndex& parent=QModelIndex()) const;

QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;

private:
structOrders m_ModelData;
};

#endif /*CSHOPPINGCARTMODEL_H_*/and it's implementation:
#include "CShoppingCartModel.h"

CShoppingCartModel::CShoppingCartModel(QObject* parent)
: QAbstractTableModel(parent)
{
}

void CShoppingCartModel::setData(const structOrders& merchandizeOrder)
{
m_ModelData=merchandizeOrder;
reset();
}

int CShoppingCartModel::rowCount(const QModelIndex& /* parent */) const
{
return m_ModelData.size();
}

int CShoppingCartModel::columnCount(const QModelIndex& /* parent */) const
{
return 1;
}

QVariant CShoppingCartModel::data(const QModelIndex& index, int role) const
{
// invalid order setup
structOrder invalidOrder;
invalidOrder.iMerchandizeID=0;
invalidOrder.iMerchandizeQuantity=0;
invalidOrder.rMerchandizePrice=0.00;
invalidOrder.rSubtotal=0.00;
invalidOrder.strMerchandizeName=QString("");

/*
if (!index.isValid() || role!=Qt::DisplayRole)
return invalidOrder;
//return qGray(modelImage.pixel(index.column(), index.row()));
return m_ModelData.at(index.column());
*/
return QVariant();
}

QVariant CShoppingCartModel::headerData(int /* section */,
Qt::Orientation /* orientation */,
int role) const
{
if (role==Qt::SizeHintRole)
return QSize(1, 1);
return QVariant();
}

As you can see, I do not know how to return whole record as QVariant.

wysota
9th April 2008, 15:02
As you can see, I do not know how to return whole record as QVariant.

Why would you want to do that?

BTW. Don't call reset() from setData(). emit dataChanged() instead.

MarkoSan
9th April 2008, 15:18
Well, from the beggining of this thread you saw I need a table with 1 column and orders.size() columns. For data cell I will implement my own delegate, which will represent one cell containing of:
+================================================= ====================+
+ SPRITE 0,33L (QString) +
+ 2,55 EUR (qreal) 3x (qint16) 7,65 EUR (qreal) +
+---------------------------------------------------------------------+
+ PIZZA PARMA (QString) +
+ 12,23 EUR (qreal) 2x (qint16) 24,46 EUR (qreal) +
+================================================= ====================+
TOTAL: 32,11 EUR (qreal)So as I understood, every cell is QVariant and every QVariant then will contain the values form QList of
typedef struct
{
qint16 iMerchandizeID;
QString strMerchandizeName;
qreal rMerchandizePrice;
qint16 iMerchandizeQuantity;
qreal rSubtotal;
} structOrder;
So, I need a mechanismus to serialize all this info into one QVariant. Am I wrong?

wysota
9th April 2008, 15:49
Yes, you are wrong :) You need a custom delegate that will render the data fetched from a single item using different item roles (like the text, icon, etc. - your custom roles included).

And to be honest, I'd do it completely differently. I'd have a table with three columns and simply span appropriate rows across all columns.

MarkoSan
9th April 2008, 19:04
Yes, you are wrong :) You need a custom delegate that will render the data fetched from a single item using different item roles (like the text, icon, etc. - your custom roles included).

So, I can use existing model classes, existing view classes and I only reimplement delegate class?


And to be honest, I'd do it completely differently. I'd have a table with three columns and simply span appropriate rows across all columns.

The problem is that this table must be wide as little as possible, because on 17" touch monitor I am very limited with its width. About 90% of desktop (from 17") there is a some operation window. But because your ideas helped me a lot, can you provide me some screenshot, what did you mean by quote?

wysota
9th April 2008, 20:07
So, I can use existing model classes, existing view classes and I only reimplement delegate class?
Yes, that's correct. QStandardItemModel has everything you might need.


The problem is that this table must be wide as little as possible, because on 17" touch monitor I am very limited with its width. About 90% of desktop (from 17") there is a some operation window. But because your ideas helped me a lot, can you provide me some screenshot, what did you mean by quote?

I don't have a screenshot. I meant to use QTableView::setSpan().

MarkoSan
9th April 2008, 20:32
But, which delegate should I use, QItemDelegate or QAbstractItemDelegate? At this moment, I am totaly confused ... :eek::confused::crying:

wysota
9th April 2008, 22:39
The former inherits the latter, thus the choice is yours. I'd go for QItemDelegate or even QStyledItemDelegate if you use a recent version of Qt.

MarkoSan
10th April 2008, 07:05
Will the result be as in first post?

P.S.:QStyledDelegate (http://doc.trolltech.com/latest/qstyleddelegate.html) has no reference to known class, the link reports "object not found...".

wysota
10th April 2008, 09:13
Will the result be as in first post?
If you implement it correctly, then yes.


P.S.:QStyledDelegate (http://doc.trolltech.com/latest/qstyleddelegate.html) has no reference to known class, the link reports "object not found...".
QStyledItemDelegate a Qt 4.4 class, so the reference won't be valid until 4.4.0 comes out.

MarkoSan
10th April 2008, 12:20
Ok, I try to set QTableWidget (http://doc.trolltech.com/latest/qtablewidget.html)'s item delegate using method setItemDelegate (http://doc.trolltech.com/latest/setitemdelegate.html):

m_pShoppingCartTableWidget->setItemDelegate(m_pShoppingCartItemDelegate); // sets delegateIn the last line of method, I get following error:
mingw32-make
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Documents and Settings/markofr/workspace/Client'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\..\Qt\4.3.4\include\QtCore" -I"..\..\..\..\Qt\4.3.4\include\QtCore" -I"..\..\..\..\Qt\4.3.4\include\QtGui" -I"..\..\..\..\Qt\4.3.4\include\QtGui" -I"..\..\..\..\Qt\4.3.4\include\QtSql" -I"..\..\..\..\Qt\4.3.4\include\QtSql" -I"..\..\..\..\Qt\4.3.4\include" -I"c:\Qt\4.3.4\include\ActiveQt" -I"debug" -I"." -I"..\..\..\..\Qt\4.3.4\mkspecs\win32-g++" -o debug\COperationWIndow.o COperationWIndow.cpp
COperationWIndow.cpp: In member function `void COperationWIndow::createShoppingCartTableWidget()' :
COperationWIndow.cpp:336: error: `QAbstractItemDelegate' is an inaccessible base of `CShoppingCartDelegate'
mingw32-make[1]: *** [debug/COperationWIndow.o] Error 1
mingw32-make[1]: Leaving directory `C:/Documents and Settings/markofr/workspace/Client'
mingw32-make: *** [debug] Error 2Why I cannot set my own delegate??

jacek
10th April 2008, 14:05
Why I cannot set my own delegate??
Make sure you use public inheritance in CShoppingCartDelegate.

MarkoSan
11th April 2008, 10:18
So, wysota, I've finnaly setup the table view. It is blank rectangle with white background. Now, like your hint was telling me, I used QModelIndex (not subclassed). How do I notify now the model about data source, which is QList of:
typedef struct
{
qint16 iMerchandizeID;
QString strMerchandizeName;
qreal rMerchandizePrice;
qint16 iMerchandizeQuantity;
qreal rSubtotal;
} structOrder;And I've setup the view with:

m_pShoppingCartTableView->setShowGrid(false);
m_pShoppingCartTableView->setModel(m_pShoppingCartModel);
m_pShoppingCartTableView->setItemDelegate(m_pShoppingCartItemDelegate);
m_pShoppingCartTableView->horizontalHeader()->hide();
m_pShoppingCartTableView->verticalHeader()->hide();
m_pShoppingCartTableView->horizontalHeader()->setMinimumSectionSize(1);
m_pShoppingCartTableView->verticalHeader()->setMinimumSectionSize(1);I've copied this chunk of code from pixelator example and I've reused it. If i comment the first line, I still do not get grid (for instance). Does this mean view is not setup properly?

wysota
11th April 2008, 10:28
It means the model is not set up incorrectly.

MarkoSan
11th April 2008, 10:32
Ok, but how do I make model aware of its QList datasource?

wysota
11th April 2008, 10:43
If you don't feel confident in creating your own model, use QStandardItemModel and reimplement QStandardItem by adding your structure to it. I think the docs explain how to do this.

MarkoSan
11th April 2008, 12:06
Well, my friends, I've done that:
#ifndef CSHOPPINGCARTITEM_H_
#define CSHOPPINGCARTITEM_H_

#include <QStandardItem>

class CShoppingCartItem : public QStandardItem
{
Q_OBJECT

public:
CShoppingCartItem(QObject* parent=0);
};

#endif /*CSHOPPINGCARTITEM_H_*/and its .cpp companion:
#include "CShoppingCartItem.h"

CShoppingCartItem::CShoppingCartItem(QObject* parent)
: QStandardItem()
{
}and I get these errors:
mingw32-make
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Documents and Settings/markofr/workspace/Client'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\..\Qt\4.3.4\include\QtCore" -I"..\..\..\..\Qt\4.3.4\include\QtCore" -I"..\..\..\..\Qt\4.3.4\include\QtGui" -I"..\..\..\..\Qt\4.3.4\include\QtGui" -I"..\..\..\..\Qt\4.3.4\include\QtSql" -I"..\..\..\..\Qt\4.3.4\include\QtSql" -I"..\..\..\..\Qt\4.3.4\include" -I"c:\Qt\4.3.4\include\ActiveQt" -I"debug" -I"." -I"..\..\..\..\Qt\4.3.4\mkspecs\win32-g++" -o debug\moc_CShoppingCartItem.o debug\moc_CShoppingCartItem.cpp
debug\moc_CShoppingCartItem.cpp:37: error: `staticMetaObject' is not a member of `QStandardItem'
debug\moc_CShoppingCartItem.cpp: In member function `virtual void* CShoppingCartItem::qt_metacast(const char*)':
debug\moc_CShoppingCartItem.cpp:51: error: `qt_metacast' is not a member of `QStandardItem'
debug\moc_CShoppingCartItem.cpp: In member function `virtual int CShoppingCartItem::qt_metacall(QMetaObject::Call, int, void**)':
debug\moc_CShoppingCartItem.cpp:56: error: `qt_metacall' is not a member of `QStandardItem'
mingw32-make[1]: *** [debug/moc_CShoppingCartItem.o] Error 1
mingw32-make[1]: Leaving directory `C:/Documents and Settings/markofr/workspace/Client'
mingw32-make: *** [debug] Error 2What am I doing wrong?

wysota
11th April 2008, 12:24
QStandardItem is not a QObject.

MarkoSan
11th April 2008, 16:06
If you don't feel confident in creating your own model, use QStandardItemModel (http://doc.trolltech.com/latest/qstandarditemmodel.html) and reimplement QStandardItem (http://doc.trolltech.com/latest/qstandarditem.html) by adding your structure to it. I think the docs explain how to do this.

I've been searching docs and two books regarind adding custom structore to QStandardItem (http://doc.trolltech.com/latest/qstandarditem.html), however, I did not find it. I do not know how to continue, please help ... Does anyone has example?

wysota
11th April 2008, 16:38
QStandardItem docs, section "Subclassing".

MarkoSan
12th April 2008, 18:10
I've read it, wysota, but I still do not know how to integrate my struct into subclassed QStandardItem (http://doc.trolltech.com/latest/qstandarditem.html). Here is what I've done so far (it is very little), I really would need some deeper help. The header:
#ifndef CSHOPPINGCARTITEM_H_
#define CSHOPPINGCARTITEM_H_

// qt includes
#include <QStandardItem>

static const int STRUCT_ORDER_TYPE=1001;

class CShoppingCartItem : public QStandardItem
{
public:
CShoppingCartItem(QObject* parent=0);

int type() const;
};

#endif /*CSHOPPINGCARTITEM_H_*/Implementation:
#include "CShoppingCartItem.h"

CShoppingCartItem::CShoppingCartItem(QObject* parent)
: QStandardItem()
{
}

int CShoppingCartItem::type() const
{
return STRUCT_ORDER_TYPE;
}Where do I put my struct?! :crying::confused:

wysota
12th April 2008, 18:34
Either as a member variable or as a superclass. Either way you'll have to reimplement other methods mentioned in the docs if you want to use the structure for anything. But before you do, think if you do need the structure at all. You might use QStandardItem without subclassing - just use custom roles and set your data.

MarkoSan
12th April 2008, 22:09
How do I use custom roles? I've been reading docs but I still do not see the way how to do this task.

wysota
12th April 2008, 22:20
Role is simply a number. Just use setData() and data() with a number of your choice but not less than Qt::UserRole. I think the docs are quite clear about it. You can also take a look at the wiki article about models.

MarkoSan
13th April 2008, 23:29
Well, I've reimplemented QAbstractTableModel and QTableView, it works ok. The last step is to reimplement QStandardItem for delegate get to work. But right now I am confused regarding layouts. In the attachemnt there is a GUI of my application module. Well, widgets named "QPUSHBUTTON1" and "QTABLEVIEW" are connected via QVBoxLayout. This vertical layout resided with main operation's window (wich is also vertical layouted with 3 pushbuttons placed under it - the 3 pushbuttons are horiz. layouted) vertical layout in horizontal layout. Now, the layout of QPUSHBUTTON1 and QTABLEVIEW is too wide. Now, how can I make main operation window wider and QPUSHBUTTON1 with QTABLEVIEW narrower. Do I have to begin experiment with layouts or the widgets inside "actor" layouts?

wysota
14th April 2008, 07:06
You can adjust horizontal stretches and/or size policies of widgets.

MarkoSan
14th April 2008, 07:51
Well, I used resize function, but there are no results ... :confused:

wysota
14th April 2008, 10:46
Resize won't work as layouts override it. Use what I suggested.

MarkoSan
14th April 2008, 10:53
well, if I knew what you thought I would not be asking now ... :D Will go now read docs, thanks for hints and tips, wysota...

wysota
14th April 2008, 11:03
I told you the names of fields in Designer. I think I can expect someone with at least two years of experience to locate them there.

MarkoSan
14th April 2008, 11:31
Yes, wysota, do not be mad, please, you are right, but I haven't slept whole weekend because of this application. And I do not use designer, since I want to master qt by handcoding and then switch to designer ....

wysota
14th April 2008, 11:36
Yes, wysota, do not be mad, please, you are right, but I haven't slept whole weekend because of this application.
So now you see this was not a good idea. A tired man (programmers included) has a very reduced efficiency. A very tired man has no efficiency at all. Go to sleep.


And I do not use designer,
Those same names are available in Qt Assistant.


since I want to master qt by handcoding and then switch to designer ....

Bad idea.

MarkoSan
15th April 2008, 09:46
Well, ok, now I've set up all things as they should be. I've subclassed QTableView and QAbstractTableModel. It works fine for now. Just question. I've followed wysota's advice and the method data() return QVariant, which is QString stuffed with the values of all components of my struct. Wysota, did I do it right way or not?

wysota
15th April 2008, 09:56
No, I told you to use different roles for different data pieces.

MarkoSan
15th April 2008, 12:16
Ok, then back to docs ... But I do not get this roles :). I've looked them up in docs, the roles are used for editing, rendering data ... not for data type itself ...

wysota
15th April 2008, 12:45
The point is that every row consists of two lines, the upper one will hold merchandize name (solo column) and the lower one will consists of following fields in order:

* price/merchandize unit (eur formatted, including euro sign
* number of merchandize unit (formatted with leading 0)
* price/unit*number of merchandize units (eur formatted, including euro sign)
* at the end there will be total field

I see different pieces of data here, don't you?

MarkoSan
15th April 2008, 13:15
I see different pieces of data here, don't you? So, quote fomr the docs:
Each item in the model has a set of data elements associated with it, each with its own role. The roles are used by the view to indicate to the model which type of data it needs. So, for this each data from struct I need a whole familiy of this roles (numbers)?!

wysota
15th April 2008, 13:29
For each data piece you need one role.

MarkoSan
22nd April 2008, 12:37
Ok, I am slowly getting somewhere, but in the statement:
m_pShoppingCartView->model()->setData(index, QVariant((m_pShoppingCartView->order()->orders().size()), 1));

I get following error:
mingw32-make
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Documents and Settings/markofr/workspace/Client'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\..\Qt\4.3.4\include\QtCore" -I"..\..\..\..\Qt\4.3.4\include\QtCore" -I"..\..\..\..\Qt\4.3.4\include\QtGui" -I"..\..\..\..\Qt\4.3.4\include\QtGui" -I"..\..\..\..\Qt\4.3.4\include\QtSql" -I"..\..\..\..\Qt\4.3.4\include\QtSql" -I"..\..\..\..\Qt\4.3.4\include" -I"c:\Qt\4.3.4\include\ActiveQt" -I"debug" -I"." -I"..\..\..\..\Qt\4.3.4\mkspecs\win32-g++" -o debug\CMainWindow.o CMainWindow.cpp
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\..\Qt\4.3.4\include\QtCore" -I"..\..\..\..\Qt\4.3.4\include\QtCore" -I"..\..\..\..\Qt\4.3.4\include\QtGui" -I"..\..\..\..\Qt\4.3.4\include\QtGui" -I"..\..\..\..\Qt\4.3.4\include\QtSql" -I"..\..\..\..\Qt\4.3.4\include\QtSql" -I"..\..\..\..\Qt\4.3.4\include" -I"c:\Qt\4.3.4\include\ActiveQt" -I"debug" -I"." -I"..\..\..\..\Qt\4.3.4\mkspecs\win32-g++" -o debug\COperationWIndow.o COperationWIndow.cpp
../../../../Qt/4.3.4/include/QtCore/../../src/corelib/kernel/qvariant.h: In member function `void COperationWIndow::chooseMerchandize()':
../../../../Qt/4.3.4/include/QtCore/../../src/corelib/kernel/qvariant.h:415: error: `QVariant::QVariant(bool, int)' is private
COperationWIndow.cpp:284: error: within this context
mingw32-make[1]: *** [debug/COperationWIndow.o] Error 1
mingw32-make[1]: Leaving directory `C:/Documents and Settings/markofr/workspace/Client'
mingw32-make: *** [debug] Error 2

The very similiar line of code from example works fine. Why?!

MarkoSan
22nd April 2008, 13:38
Ok, I am slowly getting somewhere, but in the statement:
m_pShoppingCartView->model()->setData(index, QVariant((m_pShoppingCartView->order()->orders().size()), 1));I get following error:
mingw32-make
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Documents and Settings/markofr/workspace/Client'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\..\Qt\4.3.4\include\QtCore" -I"..\..\..\..\Qt\4.3.4\include\QtCore" -I"..\..\..\..\Qt\4.3.4\include\QtGui" -I"..\..\..\..\Qt\4.3.4\include\QtGui" -I"..\..\..\..\Qt\4.3.4\include\QtSql" -I"..\..\..\..\Qt\4.3.4\include\QtSql" -I"..\..\..\..\Qt\4.3.4\include" -I"c:\Qt\4.3.4\include\ActiveQt" -I"debug" -I"." -I"..\..\..\..\Qt\4.3.4\mkspecs\win32-g++" -o debug\CMainWindow.o CMainWindow.cpp
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\..\Qt\4.3.4\include\QtCore" -I"..\..\..\..\Qt\4.3.4\include\QtCore" -I"..\..\..\..\Qt\4.3.4\include\QtGui" -I"..\..\..\..\Qt\4.3.4\include\QtGui" -I"..\..\..\..\Qt\4.3.4\include\QtSql" -I"..\..\..\..\Qt\4.3.4\include\QtSql" -I"..\..\..\..\Qt\4.3.4\include" -I"c:\Qt\4.3.4\include\ActiveQt" -I"debug" -I"." -I"..\..\..\..\Qt\4.3.4\mkspecs\win32-g++" -o debug\COperationWIndow.o COperationWIndow.cpp
../../../../Qt/4.3.4/include/QtCore/../../src/corelib/kernel/qvariant.h: In member function `void COperationWIndow::chooseMerchandize()':
../../../../Qt/4.3.4/include/QtCore/../../src/corelib/kernel/qvariant.h:415: error: `QVariant::QVariant(bool, int)' is private
COperationWIndow.cpp:284: error: within this context
mingw32-make[1]: *** [debug/COperationWIndow.o] Error 1
mingw32-make[1]: Leaving directory `C:/Documents and Settings/markofr/workspace/Client'
mingw32-make: *** [debug] Error 2The very similiar line of code from example works fine. Why?!

Well, my mistake again, I did not take a look at this line of code carefully, sorry for this spamming post ...

MarkoSan
7th May 2008, 11:15
Ok, we are getting somewhere with this widget, but now I encountered a problem. So, I this main window class declaration I have:
CShoppingCartView* m_pShoppingCartView; In class CShoppingCart I have a pointer to internal order class:
CMerchandizeOrder* m_pOrder; and corresponding inline function:
inline CMerchandizeOrder* order()
{ return m_pOrder; }; Now, when I call:
m_pShoppingCartView->order()->orders().append(tmpOrder); // adds order to internal qlist
int iOrderSize=m_pShoppingCartView->order()->orders().size(); // calcs size
Q_ASSERT_X(iOrderSize>0, "COperationWindow.cpp", "m_pShoppingCartView->order()->orders().size()<0"); // checks sizeI get assert failure, so struct is not added to list. I do not know why, please help!!! I've doublechecked if I create qlist of orders and I do it in constructor, so that part is ok. Please help!