why im i getting expected ')' before ';' token error in qt5 - qt5

why do i get error in this code on line 17 and 18 Q::object... it says that i need to put ')' before the ';' i am confused please help.
#include <QtGui>
#include <QHBoxLayout>
#include <QSlider>
#include <QSpinBox>
int main(int argc, char *argv[]){
QGuiApplication prog(argc, argv);
QWidget *mainWindow = new QWidget;
mainWindow->setWindowTitle("how many chickens do you want");
QSpinBox *spinner = new QSpinBox;
QSlider *slider = new QSlider(Qt::Horizontal);
spinner->setRange(1,50);
slider->setRange(1,50);
QObject::connect(spinner, SIGNAL(valueChanged(int)),slider, SLOT(setValue(int));
QObject::connect(slider, SIGNAL(valueChanged(int)),spinner, SLOT(setValue(int));
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(spinner);
layout->addWidget(slider);
mainWindow->setLayout(layout);
mainWindow->show();

You're short one ')' in each line. Try this:
QObject::connect(spinner, SIGNAL(valueChanged(int)),slider, SLOT(setValue(int)));
QObject::connect(slider, SIGNAL(valueChanged(int)),spinner, SLOT(setValue(int)));

Related

Program does not stop

I'm trying to create a guessing game where you can play as many times as you want before exiting. The issue I'm having currently is this program does not stop. If you put the correct answer it will just keep saying "Match" for days on end. Same if you get it incorrect.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
main()
{
char name[10][20]= {"DUMBO","MICKEY MOUSE","GOOFY","DONALD DUCK"};
char charName[20];
int count, nameMatch;
char found;
printf("Enter the name of a Disney cartoon character ");
gets(charName);
strupr (charName);
found = 'n';
for (count=0;count<4;count++)
{ if(!strcmp(charName, name[count]))
{found = 'y';}
}
while (nameMatch == 0)
if(found == 'y')
puts("Match");
else
puts("No Match");
system("pause");
return 0;
}

Using AABB_tree with multiple surface meshes

I'm trying to use CGAL's AABB_tree with multiple Surface_mesh and fail an odd assertion which makes me think it's trying to use the first surface mesh's vertices with the second mesh's indices or something similarly weird.
Before I file a bug, I'd like to validate that I'm not misunderstanding something.
Here's a minimally modified example. I'm using cube.off from: https://github.com/libigl/libigl/blob/master/tutorial/shared/cube.off and the Tetrahedron from CGAL's examples, but it seems to reproduce every time the second surface mesh I add has less vertices than the first mesh no matter what it is.
The assertion I'm failing is /usr/local/include/CGAL/Surface_mesh/Properties.h:178 - CGAL_assertion( idx < data.size() );
Using:
CGAL_VERSION 4.12
CGAL_VERSION_NR 1041201000
CGAL_SVN_REVISION 99999
CGAL_GIT_HASH f7c3c8212b56c0d6dae63787efc99093f4383415
#include <iostream>
#include <fstream>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::Point_3 Point;
typedef K::Ray_3 Ray;
typedef CGAL::Surface_mesh<Point> Mesh;
typedef CGAL::AABB_face_graph_triangle_primitive<Mesh> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef boost::optional<Tree::Intersection_and_primitive_id<Ray>::Type> Ray_intersection;
int main(int argc, char* argv[])
{
const char* filename1 = "cube.off";
const char* filename2 = "tetrahedron.off";
std::ifstream input1(filename1);
Mesh mesh1;
input1 >> mesh1;
std::ifstream input2(filename2);
Mesh mesh2;
input2 >> mesh2;
Tree tree;
tree.insert(faces(mesh1).first, faces(mesh1).second, mesh1);
tree.insert(faces(mesh2).first, faces(mesh2).second, mesh2);
tree.build(); // CGAL_assertion( idx < data.size() ) fails
return 0;
}
I repost my comment as an answer:
From my comment: Actually you can use this primitive but you need to set the template tag OneFaceGraphPerTree to CGAL::Tag_false.
See here

Read status of FT245RL pins

Sorry for my ignorance but I am very new in FTDI chip Linux software development.
I have module based on FT245RL chip, programmed to be 4 port output (relays) and 4 port opto isolated input unit.
I found out in Internet program in C to turn on/off relays connected to outputs D0 to D3. After compiling it works properly. Below draft of this working program:
/* switch4.c
* # gcc -o switch4 switch4.c -L. -lftd2xx -Wl,-rpath,/usr/local/lib
* Usage
* # switch4 [0-15], for example # switch4 1
* */
#include <stdio.h>
#include <stdlib.h>
#include "./ftd2xx.h"
int main(int argc, char *argv[])
{
FT_STATUS ftStatus;
FT_HANDLE ftHandle0;
int parametr;
LPVOID pkod;
DWORD nBufferSize = 0x0001;
DWORD dwBytesWritten;
if(argc > 1) {
sscanf(argv[1], "%d", ¶metr);
}
else {
parametr = 0;
}
FT_SetVIDPID(0x5555,0x0001); // id from lsusb
FT_Open(0,&ftHandle0);
FT_SetBitMode(ftHandle0,15,1);
pkod=&parametr;
ftStatus = FT_Write(ftHandle0,pkod,nBufferSize,&dwBytesWritten);
ftStatus = FT_Close(ftHandle0);
}
My question is. How can I read in the same program, status of D4 to D7 pins, programmed as inputs? I mean about "printf" to stdout the number representing status (zero or one) of input pins (or all input/output pins).
Can anybody help newbie ?
UPDATE-1
This is my program with FT_GetBitMode
// # gcc -o read5 read5.c -L. -lftd2xx -Wl,-rpath,/usr/local/lib
#include <stdio.h>
#include <stdlib.h>
#include "./ftd2xx.h"
int main(int argc, char *argv[])
{
FT_STATUS ftStatus;
FT_HANDLE ftHandle0;
UCHAR BitMode;
FT_SetVIDPID(0x5555,0x0001); // id from lsusb
ftStatus = FT_Open(0,&ftHandle0);
if(ftStatus != FT_OK) {
printf("FT_Open failed");
return;
}
FT_SetBitMode(ftHandle0,15,1);
ftStatus = FT_GetBitMode(ftHandle0, &BitMode);
if (ftStatus == FT_OK) {
printf("BitMode contains - %d",BitMode);
}
else {
printf("FT_GetBitMode FAILED!");
}
ftStatus = FT_Close(ftHandle0);
}
But it returns "FT_GetBitMode FAILED!" instead value of BitMode
FT_GetBitMode returns the instantaneous value of the pins. A single byte will be
returned containing the current values of the pins, both those which are inputs and
those which are outputs.
Source.
Finally I found out whats going wrong. I used incorrect version of ftdi library. The correct version dedicated for x86_64 platform is located here:
Link to FTDI library

Thread breakpoint error at custom function

I am trying to compile this simple program on Xcode 5 and I'm getting a "thread 1: breakpoint 1.1" message at error line below. Anyone know how I can fix it?
Here's my code:
#import <Foundation/Foundation.h>
int totalSavings(int listTotal);
int main(int argc, const char * argv[])
{
#autoreleasepool {
int itemEntry, itemEntry1, itemEntry2,
listTotal, calcSavings;
itemEntry = 320;
itemEntry1 = 218;
itemEntry2 = 59;
listTotal = itemEntry + itemEntry1 + itemEntry2;
calcSavings = totalSavings(listTotal); \\error line
NSLog(#"Total Planned Spending: %d \n Amount Saved: %d", listTotal,
calcSavings);
}
return 0;
}
int totalSavings(int listTotal)
{
int savingsTotal;
savingsTotal = 700 - listTotal;
return savingsTotal;
}
Including the type int in the call is incorrect syntax.
The line in error:
calcSavings = totalSavings(int listTotal);
The fixed line:
calcSavings = totalSavings(listTotal);
The error message is:
Untitled.m:16:36: error: expected expression
calcSavings = totalSavings(int listTotal); // error line
^
Notice the "^" just under int, this is a clear indication of where the error is.

Objective-c runtime SIGSEGV on descrption

I am playing with the objective-c runtime and getting a SIGSEGV when trying to print the description of an object:
#include <objc/runtime.h>
#include <stdio.h>
#include <stdlib.h>
int
main()
{
// SEL sAlloc = sel_registerName("alloc");
SEL sInit = sel_registerName("init");
SEL sDesc = sel_registerName("description");
id desc;
Class nAuto = (Class)objc_getClass("NSAutoreleasePool");
Class nObject = (Class)objc_getClass("NSObject");
// Avoid __NSAutoreleaseNoPool warrning
id nsAuto = class_createInstance(nAuto, 0);
objc_msgSend(nsAuto, sInit);
id ns = class_createInstance(nObject, 0);
objc_msgSend(ns, sInit);
desc = objc_msgSend(ns, sDesc);
printf("%s\n", class_getName(ns->isa));
printf("%s\n", class_getName(desc->isa)); // SIGSEGV triggered
NSLog(desc);
return EXIT_SUCCESS;
}
So if anyone got an idea why this is happening. Thanks
objc_msgSend must be cast before used:
desc = (IMP)objc_msgSend(ns, sDesc);