'Camera' does not name a type BB10 - blackberry

#ifndef CAMERAHANDLER_H_
#define CAMERAHANDLER_H_
#include <QtCore/QObject>
class CameraHandler: public QObject
{
Q_OBJECT
public:
//… constructor destructor etc
void setupControls(const QString &camName, const QString &vfButtonName);
Q_INVOKABLE void camerastart();
Q_INVOKABLE void camerastop();
private slots:
void onOpenSuccess(); //when camera is opened successfully
void onShutterFired(); //when we get shutterfired event
void onButtonClick(); //when the button is clicked
void onStopVfSuccess(); //when viewfinder has been stopped
void onStartVfSuccess(); //when viewfinder has been started
private:
Camera* m_camera;
Button* m_camButton;
bool m_ViewfinderOn;
bool m_cameraopen;
//const bb::cascades::AbstractPane *m_abstractPane;
};
#endif /* CAMERAHANDLER_H_ */
I have file Camerahandler.h file in src folder Cascades Framework to develop BB10 app.
But i receive error "'Camera' does not name a type" & "'Button' does not name a
type". Please help me fix!

How about if you add these two?
#include <bb/cascades/multimedia/Camera>
#include <bb/cascades/Button>

Related

c++builder linker problem with Abbrevia GetIt package : ilink32 error unresolved external

I am trying to use the abbrevia package ( https://github.com/TurboPack/Abbrevia ) with c++Builder in a console application.
First i tried to manually install the package. But then i found it on GetIt. Issue persists no matter how it setup the package. I think the path settings i did manually are the same as the package installer did.
It results always in unresolved externel for Abdfbase::TAbDeflateHelper::
This is the original error message:
[ilink32 Fehler] Error: Nicht auflösbares externes 'Abdfbase::TAbDeflateHelper::' referenziert von c:\pathtotheobjectfile\main.obj
Just setting up the path and compiling the projects for the c++builder ( therefore getting the objects ) is all the setup aks for. And with GetIt i dont even have to do that.
This is my most simple start which i cant even get to link.
#pragma hdrstop
#pragma argsused
#ifdef _WIN32
#include <tchar.h>
#else
typedef char _TCHAR;
#define _tmain main
#endif
#include <stdio.h>
#include <AbDfBase.hpp>
using namespace Abdfbase;
int _tmain(int argc, _TCHAR* argv[])
{
TAbDeflateHelper* helper = new TAbDeflateHelper();
return 0;
}
This is my first try using c++builder. What system setting or special code am I missing?
For reference the start of the .hpp imported which show the class i try to instantiate.
/ CodeGear C++Builder
// Copyright (c) 1995, 2021 by Embarcadero Technologies, Inc.
// All rights reserved
// (DO NOT EDIT: machine generated header) 'AbDfBase.pas' rev: 35.00 (Windows)
#ifndef AbdfbaseHPP
#define AbdfbaseHPP
#pragma delphiheader begin
#pragma option push
#pragma option -w- // All warnings off
#pragma option -Vx // Zero-length empty class member
#pragma pack(push,8)
#include <System.hpp>
#include <SysInit.hpp>
#include <System.SysUtils.hpp>
#include <System.Classes.hpp>
//-- user supplied -----------------------------------------------------------
namespace Abdfbase
{
//-- forward type declarations -----------------------------------------------
class DELPHICLASS TAbDeflateHelper;
class DELPHICLASS TAbLogger;
class DELPHICLASS TAbNodeManager;
class DELPHICLASS EAbAbortProgress;
class DELPHICLASS EAbPartSizedInflate;
class DELPHICLASS EAbInflatePasswordError;
class DELPHICLASS EAbInternalInflateError;
class DELPHICLASS EAbInflateError;
class DELPHICLASS EAbInternalDeflateError;
class DELPHICLASS EAbDeflateError;
//-- type declarations -------------------------------------------------------
typedef System::StaticArray<int, 536870911> TAbDfIntegerList;
typedef TAbDfIntegerList *PAbDfIntegerList;
typedef void __fastcall (__closure *TAbProgressStep)(int aPercentDone);
class PASCALIMPLEMENTATION TAbDeflateHelper : public System::TObject
{
typedef System::TObject inherited;
private:
int FAmpleLength;
int FChainLength;
System::UnicodeString FLogFile;
int FMaxLazy;
TAbProgressStep FOnProgressStep;
int FOptions;
__int64 FPartSize;
__int64 FSizeCompressed;
__int64 FSizeNormal;
__int64 FStreamSize;
int FWindowSize;
System::WideChar FZipOption;
protected:
void __fastcall dhSetAmpleLength(int aValue);
void __fastcall dhSetChainLength(int aValue);
void __fastcall dhSetLogFile(const System::UnicodeString aValue);
void __fastcall dhSetMaxLazy(int aValue);
void __fastcall dhSetOnProgressStep(TAbProgressStep aValue);
void __fastcall dhSetOptions(int aValue);
void __fastcall dhSetWindowSize(int aValue);
void __fastcall dhSetZipOption(System::WideChar aValue);
public:
__fastcall TAbDeflateHelper();
void __fastcall Assign(TAbDeflateHelper* aHelper);
__property int AmpleLength = {read=FAmpleLength, write=dhSetAmpleLength, nodefault};
__property int ChainLength = {read=FChainLength, write=dhSetChainLength, nodefault};
__property System::UnicodeString LogFile = {read=FLogFile, write=dhSetLogFile};
__property int MaxLazyLength = {read=FMaxLazy, write=dhSetMaxLazy, nodefault};
__property int Options = {read=FOptions, write=dhSetOptions, nodefault};
__property __int64 PartialSize = {read=FPartSize, write=FPartSize};
__property System::WideChar PKZipOption = {read=FZipOption, write=dhSetZipOption, nodefault};
__property __int64 StreamSize = {read=FStreamSize, write=FStreamSize};
__property int WindowSize = {read=FWindowSize, write=dhSetWindowSize, nodefault};
__property __int64 CompressedSize = {read=FSizeCompressed, write=FSizeCompressed};
__property __int64 NormalSize = {read=FSizeNormal, write=FSizeNormal};
__property TAbProgressStep OnProgressStep = {read=FOnProgressStep, write=dhSetOnProgressStep};
public:
/* TObject.Destroy */ inline __fastcall virtual ~TAbDeflateHelper() { }
};
Setting up search paths doesn't tell the compiler/linker which specific libraries you are actually using. Your project is not linking to the Abbrevia package library, hence the error.
Had you created a GUI app instead and visually dropped the Abbrevia component(s) onto a TForm, TFrame, or TDataModule at design-time, the necessary package library reference(s) would have been added for you.
But, in a console app, without at least a TDataModule, you will have to manually add reference(s) to Abbrevia's .bpi package library(s) to the project.

Register for Darwin Notification and send event details via Callback - Codename One

I am trying to create a test App with Codename One that listens out for displayStatus change via Darwin Notifications and sends the events via callback to the Java side. I have very very little knowledge of C and almost no knowledge of objective C so most of the code i have for that part was lifted and joined from several places in the web. I have followed the developer guide but the build fails on the cloud. So far i have done the following:
In my start method i have this:
public void start() {
if(current != null){
current.show();
return;
}
Form hi = new Form("Xerveur", new LayeredLayout());
hi.add(buildRootContainer()).add(buildRootChildContainer());
Display.getInstance().callSerially(hi::show);
registerForNativeCallback();
}
This registers for the native interface:
private void registerForNativeCallback(){
NativeListener listener = NativeLookup.create(NativeListener.class);
if( listener != null && listener.isSupported() ){
Log.p("Setup Event Listener returned: " + listener.setupEventListener());
}
}
The above code snippets are in the main class file. The NativeListener interface is simple:
public interface NativeListener extends NativeInterface {
public boolean setupEventListener();
}
Now i have a simple callback class which is supposed to receive a string, having the required information from the native side:
public class NativeCallback {
public static void receive(String payload){
Log.p(payload);
}
}
These are the contents of the ".m" file that was generated (the ".h" file is unmodified from what was auto-generated) and i edited:
#import "ca_ratelsoft_testing_testapp2_NativeListenerImpl.h"
#include "ca_ratelsoft_testing_testapp2_NativeCallback.h"
#include "CodenameOne_GLViewController.h"
#include <unistd.h> // good idea in general
#include <stdlib.h> // good idea in general
#include <CoreFoundation/CoreFoundation.h>
#include <notify.h> // for all notifications
#implementation ca_ratelsoft_testing_testapp2_NativeListenerImpl
-(BOOL)setupEventListener{
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), //center
NULL, // observer
displayStatusChanged, // callback
CFSTR("com.apple.springboard.displayStatus"), // event name
NULL, // object
CFNotificationSuspensionBehaviorDeliverImmediately);
return YES;
}
static void displayStatusChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
NSLog(#"event received!");
// you might try inspecting the `userInfo` dictionary, to see
// if it contains any useful info
if (userInfo != nil) {
const void * keys;
const void * values;
NSString *payload = #"displayStatus$$$"; //delimeter: $$$
CFDictionaryGetKeysAndValues(userInfo, &keys, &values);
//key1=value1;key2=value2;
for (int i = 0; i < CFDictionaryGetCount(userInfo); i++) {
const char * keyStr = CFStringGetCStringPtr((CFStringRef)&keys[i], CFStringGetSystemEncoding());
const char * valStr = CFStringGetCStringPtr((CFStringRef)&values[i], CFStringGetSystemEncoding());
if( i > 0 )
payload = [payload stringByAppendingString:#";"];
payload = [payload stringByAppendingString:#(keyStr)];
payload = [payload stringByAppendingString:#"="];
payload = [payload stringByAppendingString:#(valStr)];
}
ca_ratelsoft_testing_testapp2_NativeCallback_receive___java_lang_String(CN1_THREAD_GET_STATE_PASS_ARG fromNSString(CN1_THREAD_GET_STATE_PASS_ARG payload));
}
}
-(BOOL)isSupported{
return YES;
}
#end
I get the following error when building a debug iOS app: https://www.dropbox.com/s/sq8f00nzf445gp0/f9e35511-c43f-4bb6-854a-f513ec8e3820-1500397464685-error.txt?dl=0
First lets start with the error, if you scroll to the bottom you will see NativeListenerImpl.o is mentioned. If you search for NativeListenerImpl in the file you will see the compilation code for that and the actual error right below it:
src/ca_ratelsoft_testing_testapp2_NativeListenerImpl.m:2:10: fatal error: 'ca_ratelsoft_testing_testapp2_NativeCallback.h' file not found
#include "ca_ratelsoft_testing_testapp2_NativeCallback.h"
^
1 error generated.
This happens because our optimizer is over eager to remove unused code and can't find the usage of callback. You can solve this by adding the following code to your main class:
boolean fakeVariable;
public void init(Object o) {
// ... rest of code
if(fakeVariable) {
NativeCallback.receive(null);
}
}
This is important. Don't make the variable private!!!
The variable is package protected and will always be false so that code will never occur. In theory some code can change that flag so the optimizer can't detect that and will be forced to leave that code in place.

QTimer does not fire (trigger) timeout

I want to use Qtimer to pause executing of given block of codes, while in another thread it does something else. I connected the timeout of the thread with qeventloop quit, but the problem is, that the timeout is not called. When another emit occures, the timeout is magically triggered or if I add another connect the time out is triggered too. I think I miss something about the use of qtimer, qeventloop and qthread. Can anyone help? I extracted the basic code for testing and put it here:
main.cpp
#include "widget.h"
#include <QApplication>
#include "tim.h"
#include <QThread>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget *w=new Widget();
tim *t=new tim();
QThread *thread=new QThread();
t->moveToThread(thread);
thread->start();
QThread::connect(w,SIGNAL(signalDoIt()),t,SLOT(slotDoIt()),Qt::QueuedConnection);
QThread::connect(w,SIGNAL(signalQuitTimer()),t,SLOT(slotQuitTimer()),Qt::QueuedConnection);
QThread::connect(t,SIGNAL(signalSetText(QString)),w,SLOT(slotSetText(QString)),Qt::QueuedConnection);
w->show();
return a.exec();
}
tim.h
#ifndef TIM_H
#define TIM_H
#include <QObject>
#include<QTimer>
#include<QTime>
#include<QEventLoop>
#include<QThread>
#include<QDebug>
class tim : public QObject
{
Q_OBJECT
public:
tim();
~tim();
signals:
void signalSetText(QString);
public slots:
void slotDoIt();
void slotQuitTimer();
void slotShowTime();
private:
QTimer *trainingTimer;
QEventLoop loopTrainingWait;
QTime time;
};
#endif // TIM_H
tim.cpp
#include "tim.h"
tim::tim()
{
qDebug()<<"constructor";
trainingTimer=new QTimer(this);
trainingTimer->setTimerType(Qt::PreciseTimer);
trainingTimer->setSingleShot(true);
QThread::connect(trainingTimer,SIGNAL(timeout()),&loopTrainingWait,SLOT(quit()));
// QThread::connect(trainingTimer,SIGNAL(timeout()),this,SLOT(slotShowTime())); //to uncomment all works, but withou this, it does not
}
void tim::slotDoIt()
{
trainingTimer->start(5000);
time.start();
loopTrainingWait.exec();
QString text(QString::number(loopTrainingWait.isRunning())+" "+ QString::number(time.elapsed()));
qDebug()<<text;
emit signalSetText(text);
}
void tim::slotShowTime()
{
QString text(QString::number(loopTrainingWait.isRunning())+" slot "+ QString::number(time.elapsed()));
qDebug()<<text;
emit signalSetText(text);
}
void tim::slotQuitTimer()
{
if(loopTrainingWait.isRunning())
loopTrainingWait.quit();
if(trainingTimer->isActive())
trainingTimer->stop();
}
tim::~tim()
{
}
//gui for testing
widget.h
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
public slots:
void slotSetText(QString text);
signals:
void signalDoIt();
void signalQuitTimer();
private slots:
void on_pushButton_clicked();
void on_pushButton_2_clicked();
void on_pushButton_3_clicked();
private:
Ui::Widget *ui;
};
#endif // WIDGET_H
widget.cpp
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
}
void Widget::slotSetText(QString text)
{
ui->label->setText(text);
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_pushButton_clicked()
{
this->close();
}
void Widget::on_pushButton_2_clicked()
{
emit signalDoIt();
}
void Widget::on_pushButton_3_clicked()
{
emit signalQuitTimer();
}
I met the same issue,and eventually I wrote SLOT between public and :,then it works
the problem was in static qeventloop, making this dynamic
loopTrainingWait=new QEventLoop(this);
with parent this, resolved the issue

Any alternative solution for QMessagebox for IOS development (QWidget application only)?

I am using Qt 5.3 and trying to develop application for IOS.
Problem is, QWidget application in a iPhone Retina simulator:
QMessage becomes full-screen.
In Application output panel I see: This plugin does not support
propagateSizeHints().
So looking for alternative solution for QMessageBox. I don't want to learn QML yet.
If you do an overlay on top of your widget you can make something similar to the iOS popups.
Basically you create another widget, and you parent it to the widget you want it to be drawn on top of.
Here are some helpful flags and lines of code to put in your overlay constructor:
setPalette(Qt::transparent);
// if you have buttons on this overlay you probably don't want this one
setAttribute(Qt::WA_TransparentForMouseEvents);
QGraphicsDropShadowEffect * dse = new QGraphicsDropShadowEffect();
dse->setBlurRadius(20);
this->setGraphicsEffect(dse);
Then be sure to command a resize of your overlay when the parent widget resizes:
void ParentWidget::resizeEvent(QResizeEvent *event)
{
overlay->resize(event->size());
event->accept();
}
http://www.qtcentre.org/wiki/index.php?title=Widget_Overlay
UPDATE: Awesome example
main.cpp
#include <QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
w.resize(300,600);
return a.exec();
}
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "overlaydialogbox.h"
#include <QResizeEvent>
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
public slots:
void resizeEvent(QResizeEvent *event);
private:
OverlayDialogBox * m_overlay;
};
#endif // MAINWINDOW_H
mainwindow.cpp
#include "mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
m_overlay = new OverlayDialogBox(this);
}
MainWindow::~MainWindow() { }
void MainWindow::resizeEvent(QResizeEvent *event)
{
m_overlay->resize(event->size());
event->accept();
}
overlaydialogbox.h
#ifndef OVERLAYDIALOGBOX_H
#define OVERLAYDIALOGBOX_H
#include <QWidget>
class OverlayDialogBox : public QWidget
{
Q_OBJECT
public:
explicit OverlayDialogBox(QWidget *parent = 0);
signals:
void accepted();
void rejected();
void finished(int);
public slots:
};
#endif // OVERLAYDIALOGBOX_H
overlaydialogbox.cpp
#include "overlaydialogbox.h"
#include <QGridLayout>
#include <QGraphicsEffect>
#include <QLabel>
#include <QDialogButtonBox>
#include <QMessageBox>
#include <QIcon>
OverlayDialogBox::OverlayDialogBox(QWidget *parent) :
QWidget(parent)
{
setPalette(Qt::transparent);
// if you have buttons on this overlay you probably don't want this one
// setAttribute(Qt::WA_TransparentForMouseEvents);
QGraphicsDropShadowEffect * dse = new QGraphicsDropShadowEffect();
dse->setBlurRadius(20);
this->setGraphicsEffect(dse);
QGridLayout * grid = new QGridLayout();
this->setLayout(grid);
QMessageBox * msg = new QMessageBox(QMessageBox::Warning,"Testing","This is a test QMessageBox.");
QObject::connect(msg, SIGNAL(accepted()), this, SIGNAL(accepted()));
QObject::connect(msg, SIGNAL(finished(int)), this, SIGNAL(finished(int)));
QObject::connect(msg, SIGNAL(rejected()), this, SIGNAL(rejected()));
QObject::connect(msg, SIGNAL(finished(int)), this, SLOT(close()));
msg->setPalette(Qt::white);
grid->addWidget(msg);
}
Hope that helps.

Builder c++ TButton problems?

I'm using Builder C++ 6.
in the folowing code I want my function KreirajPOlja() to generate random AnsiString characters on the buttons but what i always gain is just matrix 9*9 with just one generated character as in the picture:
void __fastcall TForm1::KreirajPolja()
{
int tr;
for(int i=0;i<dim_x;i++)
for(int j=0;j<dim_y;j++) {
Dugme[i][j]->Height=20;
Dugme[i][j]->Width=Dugme[i][j]->Height;
Dugme[i][j]->Left=i*Dugme[i][j]->Height;
Dugme[i][j]->Top=j*Dugme[i][j]->Height;
Dugme[i][j]->Parent=this;
tr=PostaviRandom();
Dugme[i][j]->Caption= NizSlova[tr];
}
Button1->Caption="submit";
Button1->Enabled=false;
Form1->Width=dim_x* 20+5;
Form1->Height=(dim_y+2)* 20+25;
}
//---------------------------------------------------------------------------
int __fastcall TForm1::PostaviRandom(){
int k;
srand(time(0));
k=rand()%sizeof(NizSlova);
return k;}
and here is the folowing cpp code
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <time.h>
//--- ------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
void __fastcall FormCreate(TObject *Sender);
public: // User declarations
TButton*** Dugme;
TImage *** Slike;
TEdit *brojac;
int dim_x, dim_y;
int vrijeme,kr;
int BrojSlova, br;
AnsiString NizSlova;
__fastcall TForm1(TComponent* Owner);
void __fastcall KreirajSlova();
void __fastcall AlocirajProstor();
void __fastcall BrisiProstor();
void __fastcall AlocirajProstorZaSlova();
void __fastcall BrisiProstorZaSlova();
void __fastcall KreirajPolja();
virtual int __fastcall PostaviRandom();
AnsiString __fastcall DajSlovo();
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
Don't call srand in your loop. Call it once at the start of the program.
Each time you call srand you reset the random number generator. Since you call it with the same parameter each time (your code runs in less than a second so the value of time(NULL) doesn't change), you get the same result from rand().
There is no need to call srand multiple times in the same program unless you intentionally want to reproduce an old sequence of random numbers.

Resources