How I must to use "setValidator" - qt

I wrote QIntValidator:
validator = new QIntValidator(-30,+30,this);
ui->Value_TavRotante_Calib->setValidator(validator);
but It works only for numbers<-30 and it doesn't work for numbers>30

Related

I imported a pokemon project to gmx

// but the code is throwing unexpected terminal operator new
function MovePokemon(argument0, argument1) {
old = argument0;
new = argument1;
TPartyID = global.PartyID[old]
global.PartyID[old] = global.PartyID[new]
global.PartyID[new] = TPartyID;
new is a keyword in the current versions of GameMaker, so you'll need to rename that variable (say, to _new).
The project in question may leave some to be desired given the complete absence of local variable declarations (var).
Try use this code in your script to avoid use "new"
function MovePokemon(argument0, argument1) {
TPartyID = global.PartyID[argument0]
global.PartyID[argument0] = global.PartyID[argument1]
global.PartyID[argument1] = TPartyID;

GDI compatiable with direct2d not working when using pushlayer and poplayer

I am working on a project, and try to convert GDI rendering into direct2d rendering.
Sometimes I need to use ID2D1GdiInteropRenderTarget interface to rendering some GDI content to direct2d's render target.
Here is the problem:
If I use GetDC() ReleaseDC() between PushLayer and PopLayer. The content rendered to the HDC is gone, not composited into rendertarget. But If I use GerDC() ReleaseDC between PushAxisAlignedClip and PopAxisAlignedClip, it works correctly.
Why It doesn't work between PushLayer and PopLayer, I need to use pushlayer to clip a round rect regeion.
Code is like as follows:
ID2D1HwndRenderTarget* render_target = NULL;
ID2D1GdiInteropRenderTarget* gdi_render_target = NULL;
//create ID2D1HwndRenderTarget and query ID2D1GdiInteropRenderTarget...
render_target->BeginDraw();
D2D1_LAYER_PARAMETERS params = D2D1::LayerParameters(round_rect, round_rect_geometry);
render_target->PushLayer(params, render_layer_);
HDC hdc = NULL;
gdi_render_target->GetDC(D2D1_DC_INITIALIZE_MODE_COPY, &hdc);
// Draw Line with hdc. some code is Omit.
::MoveToEx(hdc, rc.left, rc.top, &ptTemp);
::LineTo(hdc, rc.right, rc.bottom);
gdi_render_target->ReleaseDC(0);
render_target->PopLayer();
render_target->EndDraw();

Conditional classname and text (Rails)

I'm pretty new to Rails and trying some basic stuff like conditional classes.
On the 'show' view I have an element that changes styling depending on the stock availability, but also the text changes accordingly.
People keep saying the controller should be as small as possible, but placing this conditional in the view also feels dirty. Is this really the best way?
Current controller:
def show
#tyre = Tyres::Tyre.find_by_id(params[:id])
if #tyre.in_stock
#availability = I18n.t("products.filter.other.in_stock")
#availability_class = 'i-check-circle color--success'
else
#availability = I18n.t("products.filter.other.not_in_stock")
#availability_class = 'i-cross-circle color--important'
end
end
Edit:
Controller:
def show
#tyre = Tyres::Tyre.find_by_id(params[:id])
if #tyre.in_stock
#availability_append = ".in_stock"
else
#availability_append = ".not_in_stock"
end
#availability = I18n.t("products.filter.other#{#availability_append}")
end
View:
.xs-12.description__status
%i{class: (#tyre.in_stock? ? 'i-check-circle color--success' : 'i-cross-circle color--important')}
= #availability
You can clean your controller tyres_controller.rb (i suppose) method,
def show
#tyre = Tyre.find(params[:id]) # I believe you have a model named 'tyre'
end
Then, there will be a file named tyres_helper.rb in your myproject/app/helpers/. Put the following code there,
def tyre_availability(tyre) # it'll return an array with two values, first one is class name, second one is localized value
if tyre.in_stock
return 'i-check-circle color--success', I18n.t("products.filter.other.in_stock")
else
return 'i-cross-circle color--important', I18n.t("products.filter.other.not_in_stock")
end
end
and, in the view you can use,
.xs-12.description__status
%i{:class => tyre_availability(#tyre)[0]}
= tyre_availability(#tyre)[1]

QT Phonon on Windows 7

I have to say I'm kinda newbie with QT stuff.
I've tried to get to work Phonom using sample of code:
audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
mediaObject = new Phonon::MediaObject(this);
metaInformationResolver = new Phonon::MediaObject(this);
Phonon::createPath(mediaObject, audioOutput);
mediaObject->setCurrentSource(Phonon::MediaSource(":/sound/beep.wav"));
mediaObject->play();
The only warning that apears while compilation is:
"WARNING: Phonon::createPath: Cannot connect Phonon::MediaObject ( no objectName ) to Phonon::AudioOutput ( no objectName ). " - it's results with no sound.
I tried to set device output by hand with no results. Meanwhile checked qmediaplayer example - which works fine.
Does anyone can tell me, what I'm doing wrong?
QT += phonon also included
well first of all I'm not sure why you are calling create path() 2 times at line 3 and 5 with same arguments then i'll try setting source before connecting but i don't think this are the real problems
to me this worked:
Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput();
Phonon::MediaObject *mediaObject = new Phonon::MediaObject();
mediaObject->setCurrentSource(Phonon::MediaSource("PathToFile"));
Phonon::createPath(mediaObject, audioOutput);
Phonon::MediaObject *metaInformationResolver = new Phonon::MediaObject();
mediaObject->play();

AS 3.0 Duplicate Variable Definition

How do I resolve the error of duplicate variable definitions? There has to be
separate namespaces and use for each definition, but I'm just not seeing it.
CODE
I didn't write this, but I've been trying to unpackage it and change the classes and seem to have broken it. I want to use this for time-scaling the playback of my movies.There's cool math in here for time-scaling.
//time-scaling script
import flash.display.*;
import flash.events.Event.*;
var _time_scale:Number = .25;
var _frames_elapsed:int = 0;
var _clip:MovieClip;
function Main():void {
_clip = new SomeClip;
addEventListener(Event.ENTER_FRAME, handleEnterFrame);
//integer??
function handleEnterFrame(e:Event):void {
_frames_elapsed ++;
}
// we multiply the "real" time with our timescale to get the scaled time
// we also need to make sure we give an integer as a parameter, so we use Math.round() to round the value off
_clip.gotoAndStop(Math.round(_clip.totalFrames * _frames_elapsed * _time_scale ));
}
var myTimer:Timer = new Timer(10);
myTimer.addEventListener(TimerEvent.TIMER, timerListener);
function timerListener (e:TimerEvent):void{
ball1.rotationY += 5;/////////replace function///////////
}
myTimer.start();
ERRORS
**3596**
Warning: Duplicate variable definition.
**1151**
A conflict exists with definition _clip in namespace internal
NOTES
integers, non nested loop
It's because you are missing the ending "}" of the constructor, after this line:
addEventListener(Event.ENTER_FRAME, handleEnterFrame);
And the two following lines should probably be in your constructor, not just in the class declaration:
var myTimer:Timer = new Timer(10);
myTimer.addEventListener(TimerEvent.TIMER, timerListener);
If you are using the Timer and TimerEvent classes, you should import them:
import flash.utils.Timer;
import flash.events.TimerEvent;
Also, you don't need the .* at the end of the Event import.
Another "also". You should have access modifiers on your members ie. vars, and functions. So you should really say:
private var _clip:MovieClip;
It sounds to me like you need to look into the basics of AS3. Here is a really good starting point: http://www.actionscript.org/resources/articles/611/1/Getting-started-with-Actionscript-3/Page1.html
_clip is a reserved key word, you'll have to use something else.

Resources