I have a grid that's display using a control that inherits from QTableView. Right now the grid is displayed left-to-right and then as things overflow, it goes to the next row like this
-----------
| 1 | 2 | 3 |
|------------
| 4 | | |
|------------
| | | |
-----------
but I want it to go top-to-bottom first and then as things overflow, it should go to next column like this
-----------
| 1 | 4 | |
|------------
| 2 | | |
|------------
| 3 | | |
-----------
I'm mostly a .Net developer and it's pretty trivial with .net winforms controls, but how do I get QTableView to do this?
Thanks
The data displayed is a function of your model. The best way to change the behavior is to create a proxy QAbstractTableModel that swaps the rows and the columns. How complicated this will be will be dependent on your current model. It almost sounds like you have a linear model and that the view just presents it in a table-like fashion in which case you're probably using the wrong model.
If you really do have a linear model, consider using QAbstractListModel and QListView. The QListView then has a flow property that will allow you to choose between left-to-right and top-to-bottom.
Related
I was asked to find the asymptotic complexity of the given function using recursion tree
but I'm struggling to find the correct complexity at each level
Let's draw out the first two levels of the recursion tree:
+------------------+
| Input size n |
| Work done: n^2 |
+------------------+
/ \
+--------------------+ +--------------------+
| Input size: 3n/4 | | Input size: n/3 |
| Work done: 9n^2/16 | | Work done: n^2/9 |
+--------------------+ +--------------------+
Once we've done that, let's sum up the work done by each layer. That top layer does n2 work. That next layer does
(9/16)n2 + (1/9)n2 = (43/48)n2
total work. Notice that the work done by this second level is (43/48)ths of the work done in the level just above it. If you expand out a few more levels of the recursion tree, you'll find that the next level does (43/48)2n2 work, the level below that does (43/48)3n2 work, and that more generally the work done by level l in the tree is (43/48)ln2. (Convince yourself of this - don't just take my word for it!)
From there, you can compute the total amount of work done by recursion tree by summing up the work done per level across all the levels of the tree. As a hint, you're looking at the sum of a geometric sequence that decays from one term to the next - does this remind you of any of the cases of the Master Theorem?
I am using apriori to find assocaition rules and I am running into an issue:
| rule | support | confidence | lift | coverage |
|---------------|--------------------|------------------|--------------|-------------------|
| {A} => {B} | 8.616999e-05 | 0.01502544 | 19.11896 | 0.005734940 |
| {A} => {C} | 8.944227e-05 | 0.01559602 | 49.05084 | 0.005734940 |
The manual states that Coverage:
Provides the generic function and the needed S4 method to calculate the coverage (support of the
left-hand-side) of rules.
For a small ruleset coverage is equal to support. Why does coverage differ from support for large rulesets?
From the man page for interestMeasure:
"coverage", cover, LHS-support Support of the left-hand-side of the rule, i.e., supp(X). A measure of to how often the rule can be applied. Range: [0, 1]
So, coverage is greater or (in some rare cases) equal to the support of the rule.
Sorry that this is somewhat confusing in the documentation, but, you know, we all love to maintain documentation. I will improve the documentation for coverage in the next release...
As per Paul Irish's advice I'm using border-box box sizing with a universal selector.
As part of my effort to make my site able to handle increased font sizes set by visually impaired users, I've set my header dimensions with em. It also has min-width and min-height set, but in pixels, in order that the heading block won't shrink below given minimums if the user shrinks the font.
The problem is I read that Firefox up until version 17 has a border-box with min/max height bug (also in this SO question). Given that I now have FF 30 on my machine, which I assume is common, should I be worrying about a FF browser bug from two years ago?
Just because browsershots.org and browserstack.com offer screenshots for old FF, should I worry about them? I hear about people on intranets being stuck with IE 6, 7 or 8, but might this apply to Firefox? I read that, by default, Firefox is set to automatically update itself.
(I don't think my site targets a particular enough audience to able to hazard a guess about what they'd be using or from where/with what they will be viewing.)
If I should implement a workaround for this bug, none of suggestions I've seen involve simply setting box-sixing back to content-box only for the header, and then adjusting its dimenions to suit. Can I simply do that?
It seems I may also be subject to an old FF background-image-not-displaying bug.
According to StatCounter, this is the use of old Firefox versions (July 2014):
Version | 2.0 | 3.0 | 3.5 | 3.6 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16
‰ | .2 | .8 | .2 | 1.6 | .4 | .3 | .4 | .2 | .6 | .3 | .7 | .6 | 1.4 | .6 | .6 | .8 | 1.1
Suming them all, it's 10.8 ‰ = 1.08 %
It's you who should decide if it's worth implementing a workaround for those 1% or not.
I have model implemented in titan graph database with relations presented below:
[A] ---(e1)---> [B] <---(e2)--- [C] ---(e3)---> [D]
| | | | | | |
prop:id | prop:number | | label:e3 |
| | prop:id |
label:e1 label:e2 prop:number
prop:prop1
A and B are "main vertices" (for example users), vertices B and C are "less important vertices" describing some data connected with users.
The input for the query algorithm is property id of vertex A.
I want to find all such vertices D, that are connected with A in the manner shown above. What's more I want to remember the property prop1 of the edge e1 between A and B.
More precisely, I want to efficiently retrieve pairs (prop1, numberD) where prop1 is the property of edge between A -> B (if the edge has this property), and numberD is the property number from D.
I don't know how to efficiently implement this query.
It is easy to retrieve only vertices D (using GremlinPipes):
pipe
.start(startVertex)
.outE("e1")
.inV().hasProperty("number")
.inE("e2")
.outV().hasProperty("id")
.outE("e3")
.inV().hasProperty("number");
But problems occur when I need to get also edges e1 and match them with vertices D.
I tried to compute all these steps separately, but is seems to be very inefficient.
Do you have any suggestions how to implement this (maybe using several queries) using gremlin-java or gremlin-groovy?
Thanks!
Take a look at the Pattern Match Pattern described here:
https://github.com/tinkerpop/gremlin/wiki/Pattern-Match-Pattern
startVertex.outE('e1').as('e')
.inV().hasProperty('number').inE("e2")
.outV().hasProperty("id")
.outE("e3")
.inV().hasProperty("number").as('d')
.table(t)
This should give an iterator of maps
[e:e1, d:D]
From each of these maps, you can easily extract the properties you are interested in.
http://imageshack.us/photo/my-images/707/graphpw.png/
I would like to know how I can get the number of leaf node from certain node using method or something in neo4j ?
Example.
At Node A --> contains 12 leaf nodes
At Node B --> contains 6 leaf nodes
Thanks in advance.
I would model the intermediate relationships as contains and the leaf relationships as leaf, see http://console.neo4j.org/r/ulo3yc
Then, you can do
With a setup of
create (f1{name:'folder1'}), ({name:'root'})-[:contains]->(f1)-[:leaf]-> (f2{name:'folder2'}), f1-[:leaf]->({name:'folder3'})
you can do something like
start root=node(1)
match root-[:contains*0..]->()-[:leaf]->leaf
return leaf
returning
+-------------------------+
| leaf |
+-------------------------+
| Node[2]{name:"folder2"} |
| Node[3]{name:"folder3"} |
+-------------------------+