I am using wxtreelistctrl to construct a tree and I want to store 4 columns in it, but while displaying I want to display only 2 columns. Is there any way I can do this?
With wxTreeListCtrl this is not directly supported, but you could set column width to 0 as a quick and dirty hack.
With wxDataViewCtrl itself, you can perfectly well show just some of the columns of your wxDataViewModel in the GUI control.
Related
My table consists of 2 columns: the 1st one stores some strings, the other contains a checkbox only. To make my table a little bit fancy I want to stretch the whole table to the width of its view.
Using
setStretchLastSection(true);
solves the 1st problem. The table looks better, but... OK... the last column is a bit large.
Also I can use
setSectionResizeMode(QHeaderView::Stretch);
The table looks great, but... It isn't my desire. The 1st column should be optimally at least 90% of view's width and the 2nd one small since it contains one checkbox only. Additionally the table shoub be stretched to the view's width. Any Ideas?
Here is a picture just to make my question more understandable)
Here is the solution:
Disable the stretch option for the last column
setStretchLastSection(false);
Set a fixed width for the last column
setColumnWidth(1, fixedWidth)
Stretch the first column
setSectionResizeMode(0, QHeaderView::Stretch)
a bit fancy look
I'm using a CListCtrl with my own "DrawItem" to draw some custom graphics into the first column, in front of the text. The text is moved ~20 pixels to the right for this. That part works.
If the user double-clicks the column divider in the header, Windows calculates the best column width. But of course Windows doesn't know my custom drawing. So the result is ~20 pixels too small for the first column.
How can I correct that?
Found a workaround:
I can trick MFC into thinking that the list control uses checkboxes:
pMyList->SetExtendedStyle(pMyList->GetExtendedStyle() | LVS_EX_CHECKBOXES);
The user will never ever see the system's checkboxes (because of my custom drawing), but this gives me just the space that I need.
I need to display rows in UltraGrid starting from bottom and going towards the top rather then normally where they are displayed from the top to the bottom.
Is there a setting of a property that needs to be set to achieve this display? I can't seem to find it.
Example of required layout
This functionality isn't built into the WinGrid control and you should log a new product idea on the NetAdvantage for Windows Forms product idea page for this if you are looking for this functionality.
You may be able to do something like this using a creation filter to move the existing rows if there are not enough rows to fill the grid. If you do pursue this you would still need to sort the rows so that they are already in the correct order first and they you would move the existing rows down when they don't fill the entire grid. There are more details on creation filters in the help.
I want to set color for specific rows in QTableWidget, like setAlternatingRowColors does, only I should be able to specify which rows and which color I want. I tried the following code
QBrush b (QColor(224,224,224));
item->setBackground( 0 , b );
item->setBackground( 1 , b );
item->setBackground( 2 , b );
but this code only populates the item columns with color, not the entire row.
As Qt handles all the fields of a QTableWidget in distinct QTableWidgetItems, there simply is no way to affect a complete row in your table as trivial as you suggest here. As you seem to use only standard fields and no custom "specials", you could just iterate over a rows QTableWidgetItems and set their background one by one.
The more stylish way, which would accomodate your needs, would be to use the model/View Framework of Qt to obtain the background color via the data backend using QBackgroundRole. A good starting point for this would be: http://qt-project.org/doc/qt-4.8/model-view-programming.html
It may be harder to grasp the concept behind the MVC paradigm, but it is really flexible once mastered.
I am using Qt 4.2. I have a window with two separate tables using the QTableView and QAbstractTableModel. The tables seem to have extra space below the rows ending, and to the right of the columns ending. My solution up to this point with other windows has been to calculate the size of the table (based on cell size, plus a little extra for the border) and set the fixed width and height. This solution is a pain for tables that have different size columns. I am looking for a solution where my QTableView class does not have to set its own fixed size, but rather the table just ends at the last row and column. I do not want to use setStretchLastColumn(). Any suggestions to get these tables to behave properly without having to calculate and set a fixed size would be very helpful. Thanks.