Image on a button not working properly in QT - c++

I believe that I am doing something very wrong with my image buttons. I want to do something as simple as making them change its image whenever I hover over the button or by pressing it. Stylesheets are a bit ambiguous at the moment for me.
Here is a code snip where I think I am doing wrong with it:
border-image: url(:/Data/buttonNUC_Idle.png) 0 0 0 0 stretch stretch;
hover:{border-image: url(:/Data/buttonNUC_Hover.png) 0 0 0 0 stretch stretch;};
pressed: {border-image: url(:/Data/buttonNUC_Idle.png) 0 0 0 0 stretch stretch;};
Does anyone has any idea on what I can do?
Another thing that I tried, but to no avail.
void MainWindow::on_nucButton_pressed()
{
ui->nucButton->setStyleSheet("QLineEdit {border-image: url(:/Data/buttonNUC_Pressed.png) 0 0 0 0 stretch stretch;}");
// printf("Work?\n");
}

Try this
ui->nucButton->setStyleSheet("QLineEdit {border-image: url(:/Data/buttonNUC_Pressed.png) 0 0 0 0 stretch stretch;}"
"QLineEdit:hover {border-image: url(:/Data/buttonNUC_Idle.png) 0 0 0 0 stretch stretch;}"
"QLineEdit:pressed {border-image: url(:/Data/buttonNUC_Idle.png) 0 0 0 0 stretch stretch;}");

Solved it - just copy pasted the old project code into a new project and everything worked. For some reason my Qt project got bugged and it didn't let me do it.

Related

OpenMVG mainComputeMatches.cpp input explanation

How can i compute descriptor matches using --pair_list option file (using main_ComputeMatches.cpp).
What is the format of data in the file specified by input --pair_list?
Thanks in advance for any suggestion.
You must list the image view index.
See your sfm_data.json, each image is linked to a view index.
In the pair_list file you just connect the image pair your wanna try to compute like
0 1
0 2
1 2
1 6
...
Expanding #Jack answer, you could also compact it like this:
0 1 2
1 2 6
...

Replace zeros with missing values in certain cases

I was wondering if anyone knew an easier way of doing the following:
I have a dataset of health facility caseload by year, where each observation is one health facility. Facilities were 'brought online' in different years, so some have zeros before they have values for caseload. Also, some 'discontinue', as in they did provide services, but don't any more. I would like to replace the zeros with missing values for the years in which a facility discontinued. In the following example, the 3rd and 4th facilities discontinued, so I'd like missing for y2014 for the 3rd and y2013 & y2014 for the 4th.
y2011 y2012 y2013 y2014
0 0 76 82
0 0 29 13
0 0 25 0
5 10 0 0
0 0 17 24
I tried the following, which worked, but I'm going to have many years worth of data to work on (2000-2014), so was wondering if there was a more efficient way.
replace y2014=. if y2014==0 & (y2013>0 | y2012>0 | y2011>0)
replace y2013=. if y2013==0 & ( y2012>0 | y2011>0)
replace y2012=. if y2012==0 & ( y2011>0)
I messed around with egen rowlast to identify the facilities with a zero in the last year (meaning they discontinued), but then wasn't sure where to go with it.
Your problem would benefit from a loop over the variables.
We'll initialise started to 0, change our mind about started when we see a positive value, and change any subsequent 0s to missings if started is 1.
gen started = 0
forval y = 2000/2014 {
replace started = 1 if y`y' > 0
replace y`y' = . if started == 1 & y`y' == 0
}
Note that this scheme allows re-starts.
A more general comment is that this is not the better data structure for such panel or longitudinal data. This particular problem is not too challenging, but most problems with such data will be easier after reshape long.
See here for a survey of "rowwise" technique in Stata.

How to extract names from the figure

I am working on a unix machine. and I have a list of names in .eps file format. I know I can easily grep show lines to extract my names but they're not in the same order as in the figure. is there a way to extract names from the figure while preserving the order?
example:
/ArialMT-ISOLatin1 findfont
32 scalefont
setfont
0 0 0 setrgbcolor
newpath
0 0 moveto
(King James) show
grestore
grestore
grestore
0 0 0 setrgbcolor
[] 0 setdash
5 setlinewidth
0 setlinejoin
1 setlinecap
newpath
-1013.087 5437.645 moveto
-574.44269 5148.3467 lineto
stroke
0 0 0 setrgbcolor
[] 0 setdash
5 setlinewidth
0 setlinejoin
1 setlinecap
newpath
-801.10602 5042.689 moveto
-683.66547 4973.3872 lineto
stroke
0 0 0 setrgbcolor
[] 0 setdash
5 setlinewidth
0 setlinejoin
0 setlinecap
newpath
-764.50114 5103.5574 moveto
-789.24211 5063.1816 -813.3093 5022.3968 -836.69272 4981.22 curveto
stroke
gsave [0.8480481 -0.52991926 0.52991926 0.8480481 -3204.0386 27.010243]
concat
gsave [1 0 0 -1 -1554.9214 5600.4102] concat
gsave
/ArialMT-ISOLatin1 findfont
32 scalefont
setfont
0 0 0 setrgbcolor
newpath
0 0 moveto
(M. L. King) show
...
M.L.King should go before King James but could I do this by exploiting the coordinate system?
thnx
First, I wanted to suggest to keep track of movements ie where the PostScript interpreter is putting the text, but that can be tricky since postscript is a fully fledged programming language. Another approach is to annotate your .eps files:
open a file with the 'open' command
for every show
a. get the current coordianates by 'currentpoint'. this leaves the coordinates on the stack
b. 'write' those two values into your file (as a .csv perhaps?) and the text which is going to be shown
close the file with 'closefile'
Run your annotated .eps file through a PS interpreter. Sort the generated file on the coordinates with the Unix 'sort' command, don't forget the -n option for both keys (ie y coordinate and x coordinate). And you are done.

What does [heap] or [anon] means in memps output

When I run memps command for one of the processes, I get the following lines (among others) as output.
S(CODE) S(DATA) P(CODE) P(DATA) 3D(RSS) 3D(PSS) ADDR(start-end)OBJECT NAME
-------- -------- -------- -------- ------- --------- -----------------------------
0 0 0 1592 0 0 b8ca6000-b8e54000 [heap]
0 404 0 404 0 0 b8bdc000-b8ca6000 [heap]
0 0 0 4 0 0 b6fb5000-b6fb6000 [anon]
0 0 0 20 0 0 b6fb0000-b6fb5000 [anon]
What does [heap] and [anon] means in the last column of my output.
o Anonymous memory: Memory not relating to any
named object or file within the file system is
reported as [ anon ].
The pmap command displays common names for cer-
tain known anonymous memory mappings, such as:
[ heap ]
The process heap.
[ stack ]
The process stack.
If the common name for the mapping is unknown,
pmap displays [ anon ] as the mapping name.
source
There are also 2 pdfs here
You should probably use more generic keywords for this, since the utility that you are using is just a part of the memtool suite.
Next time try something like "memtool anon" as the keywords for your search.

Parsing (partially) non-uniform text blocks in Perl

I have a file with a few blocks that look like this in a file (and in a variable, at this point in the program).
Vlan2 is up, line protocol is up
....
reliability 255/255, txload 1/255, rxload 1/255^M
....
Last clearing of "show interface" counters 49w5d
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
....
L3 out Switched: ucast: 17925 pkt, 23810209 bytes mcast: 0 pkt, 0 bytes
33374 packets input, 13154058 bytes, 0 no buffer
Received 926 broadcasts (0 IP multicasts)
0 runts, 0 giants, 0 throttles
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
3094286 packets output, 311981311 bytes, 0 underruns
0 output errors, 0 interface resets
0 output buffer failures, 0 output buffers swapped out
Here's a second block, to show you how the blocks can slightly vary:
port-channel86 is down (No operational members)
...
reliability 255/255, txload 1/255, rxload 1/255
...
Last clearing of "show interface" counters 31w2d
...
RX
147636 unicast packets 0 multicast packets 0 broadcast packets
84356 input packets 119954232 bytes
0 jumbo packets 0 storm suppression packets
0 runts 0 giants 0 CRC 0 no buffer
0 input error 0 short frame 0 overrun 0 underrun 0 ignored
0 watchdog 0 bad etype drop 0 bad proto drop 0 if down drop
0 input with dribble 0 input discard
0 Rx pause
TX
147636 unicast packets 0 multicast packets 0 broadcast packets
84356 output packets 119954232 bytes
0 jumbo packets
0 output error 0 collision 0 deferred 0 late collision
0 lost carrier 0 no carrier 0 babble 0 output discard
0 Tx pause
0 interface resets
I want to pick out certain data elements from each block, which may or may not exist in each block. For example, in the first block I posted I may want to know that there are 0 runts, 0 input errors and 0 overrun. In the second block, I might want to know that there are 0 jumbo packets, collisions, etc. If a given query isn't in the block, it's acceptable to just return na, as this is designed to be processed uniformly.
Each block is structured in a similar way to the two I posted; newlines and spaces delimiting some entries, commas delimiting others.
I have a few ideas as to how this might work. I'm unaware if there is any kind of "look back" function in Perl, but I could attempt to look for the field names (runts, "input errors", etc) and then grab the previous integer; that seems like it would be the most elegant solution for this, but I'm unsure if it's possible.
Currently, I'm doing this in Perl. Each "block" that I'm processing is actually several of these blocks (separated by double newlines). It doesn't have to be done in a single regular expressions; I believe it can be done by applying several regular expressions per block. Performance is not really a factor, as this script will run maybe once per hour.
My goal is to get all of this into a .csv file (or some other data format that's easily graphable) in an automated fashion.
Any ideas?
Edit: example output in CSV as I mentioned, which would be written line by line (for multiple entries like this) to a file as the end result. If a particular entry isn't found in the block, it is marked na in the corresponding line:
interface_name,txload,rxload,last_clearing,input_queue,output_drops,runts,....
vlan2,1,1,49w5d,0-75-0-0,0,0,....
port-channel86,1,1,31w2d,na,na,0,...
Simple hash of properties and numbers.
sub extract {
my ($block) = #_;
my %r;
while ($block =~ /(?<num>\d+) \s (?<name>[A-Za-z\s]+)/gmsx) {
my $name = $+{name};
my $num = $+{num};
$name =~ s/\A \s+//msx;
$name =~ s/\s+ \z//msx;
$r{$name} = $num;
}
return %r;
}
my $block = <<'';
Vlan2 is up, line protocol is up
⋮
my $block2 = <<'';
port-channel86 is down (No operational members)
⋮
use Data::Dumper qw(Dumper);
print Dumper {extract $block};
print Dumper {extract $block2};
I don't think a single regex could do it, nor would I want to support it if it could.
Using multiple regexes, you could easily use something like:
(\d+) runts
(\d+) input errors
...etc...
A simple array of property names and a loop could solve this pretty quickly and with very little fuss.
If you can strip down the input to smaller chunks with some preprocessing, you would be less likely to get false positives.
Here is one way to do it in awk, but this needs lots of tweak to be perfect.
But again, use SNMP.
awk '{
printf $1
for (i=1;i<=NF;i++) {
if ($i" "$(i+1)~/Input queue:/) printf ",%s",$(i+2)
if ($i~/runts/) printf ",%s",$(i-1)
if ($i~/multicast,/) printf ",%s",$(i-1)
}
print ""
}' RS="swapped out" file