With Respect To ScrollBar To Rectangle
-
@Pradeep-Kumar.M
x
andy
are for positions whilewidth
andheight
are for dimensions. -
@p3c0
import QtQuick 2.4
import QtQuick.Window 2.2Window {
id: win
visible: true
width: 700
height: 500
Rectangle
{
id: rect
width: t1.font.pixelSize * 50
height: t1.font.pixelSize * 10
color: "pink"
Text {
id: t1
text: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaajjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjaaaaaaaaaaa"
}
}
}as text size increases rectangle has to increase simultaneously , but in this case, its not increasing.
-
and one more thing it has to increase dynamically, with respect to text, please help.
-
@Pradeep-Kumar.M hmm you meant length not size. Well in that case you will need get text length and bind it with some multiplier.
Its better to use a TextArea here. Isn't it ? -
because data is coming from c++ class thats y, inserting it to rectangle directly . if so how to find text length, do we have length method for text, i didnt find it.
-
@Pradeep-Kumar.M Yes. Use
length
. -
thank u for example of scrollbar to rectangle, it worked, one issue in it is ,
when i drag down, scrollbar moving upwards, i dont want in that fashion, drag should be with respect to scrollbar, not opposite, please help me. -
@Pradeep-Kumar.M Must be some problem in your code. Try doing same as done in that example.
-
same thing i did it, will you please try, i want the scrollbar to have dragged with respect to mouse simulateonusly, not in opposite fashion, i tried,
-
@Pradeep-Kumar.M Can you explain it w.r.t to that example ? That example works fine as expected.
-
code is working fine, but the thing is scrollbar has to move w.r.t to mouse, when i want to scroll, for example in this forum if u want to scroll up, u will move your mouse up, w.r.t to scrollbar, but in the example case moving mouse upwards, scrolling takes place downwards, i mean to say opposite direction.
-
@Pradeep-Kumar.M Nope. If you scroll down the scrollbar moves down and ofcourse the image will go up and v.v. That's the intended behaviour.
-
hm k kk
-
and one more if we have implementation that works with keys press,
will it work for mouse area on clicked?. -
@Pradeep-Kumar.M Yes should work. Create a function and call that function when required.
-
you mean to say create function form ex: function sample()
{
// implementation
}mouse area{
anchors.fill: id
onclicked
{
sample()
}
} -
@Pradeep-Kumar.M Yes, so that same function can be called from Keys and MouseArea. No need to duplicate the code.
-
what i taught was if there is implementation for keys event
, their will be different implementation for mousearea alse -
@Pradeep-Kumar.M Ofcourse you will need to define a
MouseArea
as well asKeys.onUpPressed
. But if the code that moves the scrollbar is similar then no need to duplicate it. Just put it in the function and call that function. -
ya got it,
keys.onuppressed,keys.ondownpressed, coming from .js file, will the same logic work for mousearea
{
} also .