How can i sort by viewing text in QTableView? - qt

i want to sort by not original text but viewing text on QTableView!
How can i sort by viewing text?
original text
{cat : 1, dog : 2}
{cat : 2, dog : 3}
viewing text
1, 2
2, 3
i want sort by dog count! (only number)
but current sorting is by its original text

void QTableView::sortByColumn(int column, Qt::SortOrder order) can help you to sort all data as your plan.

Related

Why is the highlighted area where D is constant is not considered in this Karnaugh map?

Here is a link to the K map: http://tma.main.jp/logic/logic.php?lang=en&type=eq&eq=%28%7EA%7EBC%7ED%29+%2B+%28%7EA%7EBCD%29+%2B+%28%7EAB%7ECD%29+%2B+%28%7EABCD%29+%2B+%28A%7EB%7EC%7ED%29+%2B+%28A%7EB%7ECD%29+%2B+%28A%7EBC%7ED%29+%2B+%28A%7EBCD%29+%2B+%28AB%7EC%7ED%29+%2B+%28AB%7ECD%29+%2B+%28ABC%7ED%29+%2B+%28ABCD%29
I've also attached the screenshot below.
My questions is, if the groups should be large enough, why the highlighted area is not considered but only a subset is considered to get BD instead of D?
Thank you in advance.
The groups should be "large enough" so they cancel a variable X and NOT X out. This only works when a complete X or NOT X is hit by your selection. When you select your six selected cells you will hit the AD area completely, but not the A'D area. This means you cannot cancel them out and get just D as you want to. When you hit the whole AD and A'D area this has the meaning as: "Well, the condition depends on D and is totally unrelated to the value of A."
When written as boolean algebra you get:
AD OR A'D
(A OR A') AND D
( true ) AND D
D
That would be the goal. But since you don't cover the whole A'D area you can't make this simplification here.
To check if you have selected the correct numbers of cell in a selected area, the numbers of cells must be a value of power of 2. So it must be one of 1, 2, 4, 18, 16, ...
In this case you have the regions:
A (2*4=8)
BD (2*2=4)
B'C (2*2=4, notice how the region "wraps" around the edge of the K-map)
Keep in mind that the result for A'B'C'D is false, not true. But when you have just D in your boolean algebra like in A+D+B'C, the result would be true.

How can count words of a line and keep the id of the line with apache pig?

I have a file whith 2 columns, the first one with the id and the second on with a long text and I need to know how to count words for each id.
For example if I have these two rows:
id | line
(1, This country is beautiful)
(2, I would love to have a cup of tea)
The answer I need is:
(1, 4)
(2, 9)
I have read a lot of comments about this but everyone keeps the total numbers of each word or the total number of words without keeping the id of the line.
I would appreciate if someone could help me.
Something like:
FOREACH row GENERATE
id,
COUNT(STRSPLITTOBAG(line, " "));
This should take each row, produce the needed ID field, and then split the text based on a delimeter (here a " " value) to a bag type, where the COUNT function counts the number of items in the bag.

Set my own fixed X-axis value in a grid chart? Including symbols like "<" and ">" (QlikView)

So Im creating this grid-chart and I really want to have the following values in my X-Axis:
"<10"
"<20"
">20"
I want my graph to look something like the following graph, in the link below:
Graph example
The nodes X values does not have the lesser than (<) or bigger than(>) symbols, they are just numbers spanning from 1-30 with no extra characters. Chosing only that field as the x-axis doesnt do it, ofc. I only want those three specified values, containing the symbols (< and >), in the X-axis.
I feel like this should be a simple thing to solve, but I've tried for a while now without any succes...
Sorry about the poor example, hopefully you understand what i'm saying
Any ideas?
Thanks in advance.
Have a look at the Class function.
The class function assigns the first parameter to a class interval. The result is a dual value with a<=x
You could create a grid chart and use PplWatched and Rating as dimensions with expression count(id) using the following testdata:
Data:
load
id, class(PplWatched, 10) as PplWatched, Rating
;
load * inline [
id, PplWatched, Rating
1, 14, 4
2, 2, 2
3, 19, 5
4, 30, 4
5, 9, 1
6, 45, 5
];

Count blocks in a series

This is a simple problem, however I cannot find an elegant solution for:
Given is the following vector series:
series=c(1,2,4,5,6,1,2,4,5,6,7,8,2,4)
I now want to count blocks of this vector in the same vector; e.g. if I have a block size of 2, I would like to count the pairs 1&2, 2&4, 4&5 and so on (in total 8 unique blocks if I did the counting right).
Can you think of an easy way to program that so that I receive an output matrix with a column for the "unique block number" and a corresponding column for the counts?
One idea is to can use rollapply from zoo,
nrow(unique(rollapply(series, 2, by = 1, paste0)))
#[1] 8
You can change '2' to get combinations(block sizes) of 3, 4, etc...

Merge adiacent cells in a wx.Grid

Is it possible to merge adiacent cells in a wx.grid? I mean both horizontal as cells in a row and vertical as cells in a column.
There is a way to make text span multiple rows or columns in a grid widget. There's an example in the wxPython demo called GridSimple.py. See lines 64-67. They read as follows:
self.SetCellValue( 9, 1, "This default cell will overflow into neighboring cells, but not if you turn overflow off.");
self.SetCellSize(11, 1, 3, 3);
self.SetCellAlignment(11, 1, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE);
self.SetCellValue(11, 1, "This cell is set to span 3 rows and 3 columns");
Note: You don't need the semi-colons. I don't know why they're in the example.

Resources