logo
IRC Archive / Freenode / #qt / 2010 / May / 29 / 3
jpnurmi
pick the best idea ;)
monem
:FLOOWER:
ukkopekka
Again this same question: How can I print char in HEX?
arkascha
Can someone give me a hint, I read about half of the internet, without success...
I want to sublass QSlider, adding a legend and some additional functions
thiago_home
ukkopekka: write your own code
arkascha
Insider the constructor I create a layout and add all the widgets I require
thiago_home
ukkopekka: it's two lines
arkascha
But how can I add the layout of the widget I subclassed from, the QSlider ?!?
chakie
arkascha: sounds like your widget should not subclass QSlider, but use it in a compositional manner
thiago_home
akennedy: you should have subclassed QWidget
arkascha
not sure, considered this, but decided against.
ukkopekka
thiago_home: I just don't get it right
arkascha
that would mean I have to reimplement all routines
what for ??
thiago_home
ukkopekka: it's not very hard
ukkopekka: but if you want a cannon to kill a fly, use QByteArray::toHex
arkascha
I dont want a private member of type QSlider, but I want to subclass it.
ukkopekka
thiago_home: seems to be for me :/
chakie
arkascha: why must you subclass it?
ukkopekka
thiago_home: ok now I got it with that toHex
chakie
arkascha: you can expose the internal QSlider* if needed
arkascha
chakie: to be able to use signals and slots just like in the original QSlider
chakie: how do I "expose" it ?
chakie
[14:48] <chakie> arkascha: you can expose the internal QSlider* if needed
add an accessor method
QSlider * MyWidget::getSlider() { return m_slider; }
arkascha
chakie: I will have a look at that, but still I dont see why I must have an internal QSlider object.
chakie
[14:47] <chakie> arkascha: why must you subclass it?
why not base in on QWidget and compose other widgets as needed?
arkascha
chakie: if I dont I have to define a private QSlider object. AND I have to connect all signals and slots AND i have to reimplement all methods. What for ?
chakie: if I subclass it I can simply USE the signals, slots and methods, I'd guess.
chakie
add an accessor method
but you're stuck in your way of thinking, i won't waste my time here
arkascha
chakie: sure, sorry for wasting your time :-) I will take a look into your suggestion.
chakie
don't ask for help if only your current solution is acceptable
which is a bad solution in this case
arkascha
chakie: I did not do that, sorry. I asked for help ina detail where I am stuck. I never declared that other solutions dont work. Just looking for an elegant solution.
chakie
arkascha: ok, so you want to add extra widgets to your QSlider?
i assume a legend is soemthing that explains something?
arkascha
chakie: that was my idea, indeed.
chakie
can't it be a separate widget that's just used near a normal QSlider?
but if they must be together, i'd use composition
arkascha
chakie: that would mean to push the controls into the embracing routines, e.g. main.cpp. Not really elegant.
chakie: composition surely is the typical solution, tried that.
chakie
hm, no
you can still subclass
class LegendarySlider : public QWidget { QSlider * slider; Legend * legend; }
and some layout in there too
possibly expose the "slider" or relay the signals
arkascha
chakie: true, works, straight forward. I can subclass, but as mentioned I'd have to double all methods, signals and slots. BUT;:
chakie: I will first have to take a look into "exposition".
chakie: seems I missed something there.
chakie
double all methods? why? your LegendarySlider would perform all setup
arkascha
chakie: so thanks for the hint !
chakie
not "exposition", exposing
arkascha
chakie: typo
chakie
and it's just a word, not a fancy term for something sexy
arkascha
chakie: it is NOT sexy ? wont use it then :-))
chakie
QSlider * LegendarySlider::getSlider() { return slider; }
if someone needs to do assloads of stuff on the slider
arkascha
chakie: ah, ok. So thats all.
chakie
but i doubt you really need to have externals be able to access it
arkascha
chakie: but then the outside world has to know about the LegendarySlliders internals.
chakie
why?
arkascha
chakie: cause I first have to get the slider to for example add ticks.
chakie: that means I have to KNOW there is a QSlider in there.
chakie
that is taken care of by your class
arkascha
chakie: by an additional method, I'd guess ?
chakie
in the constructor for instance
you're thinking way too complex here
arkascha
chakie: no, I mean manipulating the LegendarySlider later on, not in the constructor.
chakie
why does it have to be manipulated?
arkascha
chakie: I'd like to be able to manipulate a LegendarySlider exactly the way I can with aQSlider
chakie
you make it an own class so that it can define stuff on its onw
own
arkascha
chakie: but that makes my class unusable for others, doesnt it ?
chakie
then add an accessor method
to me making such a class at all sounds a bit like waste of time
i'd perhaps just make the legend into an own class and use a normal QSlider
arkascha
chakie: I'd say it is the only way to program in a style that can be reused later on...
chakie
will it ever be resused? likely not
arkascha
chakie: I read something about the "The Multiple Inheritance Approach", but I dont understand that, (sorry)
chakie
that's when you use .ui files
!f component
qtassistant
chakie: [using a component] http://doc.trolltech.com/latest/designer-using-a-ui-file.html
arkascha
chakie: I always assume that my code will be reused.
chakie: I mean that is the idea of OOP, isnt it ?
chakie
so you overdesign the classes?
make them complex and hard to use
to me a class does one thing and does it well
arkascha
chakie: why hard to use ? They can be used exactly like a QSlider, so it is easy to use them.
chakie: that is the odea behind it.
chakie
anyway, i have to run
arkascha
chakie: ok, thanks !!
chakie
but don't try to base it on a QSlider subclass
therein lies dragon
arkascha
(Action) laughs out loud
philthno2
Hi, I added an ActionGroup to my toolbar and want to connect this to a QGraphicsScene (to change a state there). Should I make a slot "action_changed(QAction *new_action)" there and if yes, what's the variable in a QAction I should use to identify it? Something like "if action->text == "Foo" then changeStateToFoo()"?
Or is it better to change the state in the object that knows all the actions, and emit a stateChanged(new state) there?
(in my case, QMainWindow)
Ah, I think I should use QAction::setData() to use a QAction in in a switch-construct. Is that right?
halvors1
How hide the titlebarwidget in a window?
in a dockwidget sry*
???
richmoore3
halvors1: probably using Qt::CustomizeWindowHint
halvors1
ui->dockWidget->TitleBarWidget(Qt::CustomizeWindowHint);
or
how?
richmoore3
when you instantiate it pass that as the window flags argument to the constructor
halvors1
so it should be?
i am a noob in qt, can you come with some exemples
richmoore3
new QDockWidget("blah", parent, Qt::CustomizeWindowHint)
halvors1
so i should not use ui->dockWidget-> or someting?
richmoore3
a quick google actually suggests you can do it by calling setTitleWidget(0); actually
halvors1
C:/Users/halvors/Documents/My Dropbox/OpenRcon/src/MainWindow.cpp:9: error: 'class QDockWidget' has no member named 'setTitleWidget'
richmoore3
setTitleBarWidget(0);
halvors1
the titlebar is there, noe too :(
how
?
chakie
noe?
halvors1
ui->dockWidget_sm->setTitleBarWidget(0);
this doas not work
does
*
?
so what sould i do then?
thiago_home
why doesn't it work?
richmoore
thiago_home: i have an implementation of CN/hostname validation now that works and passes a decent set of tests
thiago_home: am i right in assuming this is too late for 4.7?
halvors1
the tittle bar is ther eindted of noting
instead*
__rob
hello
could someone point me in the right direction, I wanted some text that is a child of a frame to be paintable outside of the bounds of the parent frame
instead of getting clipped
special
where 'frame' means a widget?
__rob
a QFrame widget
yes
special
you should probably rethink what you're doing
there is Qt::WA_PaintUnclipped, but it has caveats
__rob
well no, I want to add a label
to the frame
but then I want the frame to treated as it aslways is
so I dont want to add a margin
just so my text gets painted
I would rather the text gets painted outside of its bounds and worry about padding the widget in a layout or something
special
are you aware that QLabel inherits QFrame?
__rob
It doesn't
I dont think
special
it does
__rob
ohh, ok
either way, I have a child label Widget, added inside the constuctor of a QFrame widget
I am only subclassing the QFrame widget to make my own QLabeledFrame widget
in which all it does is create a child QLabel, set the background to draw opaque, use a QFontMetrics to get the size of the QLabel, then draw it in the right place..
which works, but the top of the text gets clipped
Apetrini
I thought for a while but I can't understand how can I know about "mouseReleaseEvent" if the mousePressEvent was make inside the widget but the release outside. Any ideas ?
richmoore
Apetrini: there is an implicit grab so you get the event as normal iirc
halvors
How hide the tittlebar in a dockWidget?
Apetrini
richmoore: mmm, maybe I did some mess with the events, I will take a look, thanks
peppe
halvors: setTitleBarWidget(0) ? titleBarWidget()->hide()?
halvors
no it doesn't work :(
some other way?
aep
chicken blood
halvors
??
no ideas
Apetrini
I just realize that mouseReleaseEvent is never called after mouseMoveEvent. is this the right behaviour ?
aep
Apetrini: if you didnt release it, yes
richmoore
Apetrini: check you've got the signature of your mouseReleaseEvent handler right
Apetrini
aep: lol. I obviously released it.
aep
on the widget you are expecting the event?
Apetrini
aep, richmoore : if I just click, both mousePressEvent and mouseReleaseEvent is called
richmoore
Apetrini: and did you call the base class implementation?
Apetrini
but if I click, hold down the button, move a bit and then release, mouseReleaseEvent is never called
aep: on the widget or outside the widget doesn't make any difference
aep
show code
Apetrini
richmoore: base class implementation of what ?
aep
!testcase
qtassistant
aep: [testcase] Having a good testcase is critical for us to be able to help you. Pastebin ( http://codepad.org ) a Short, Self Contained, Correct (Compilable), Example. Read http://homepage1.nifty.com/algafield/sscce.html if you don't know how.
richmoore
Apetrini: i'm wondering if you called the base class implementation of the event handlers you've reimplemented
Apetrini
richmoore: I don't
richmoore
i don't think that should make a difference, but it might be worth a shot. i've never had any problem similar to the one you're describing
Apetrini
ahh
aep, richmoore: was the "drag->exec(..)" inside the mouseMoveEvent that blocks .
ah, now at least I found the problem, aep , richmoore, really thanks.
richmoore3
ah good
astruasdh
please, guys... is there audio support in qt framework?
Xenakios
some, but it's somewhat fragmented
different things capable of doing different things
some are easy to use but don't offer any low level control
some stuff not only allows low level stuff but requires you to implement stuff yourself
what do you want to do?
astruasdh
a voip application
Xenakios
my quick guess is that Qt doesn't offer all the necessary components for doing that
for example you are going to need some audio compression codec system, to get decent sound over the network at a low enough bandwidth
cos^
yep, nothing low level enough in qt currently
Xenakios
well, there's audio input and output in Qt Multimedia
but using that is somewhat involved
astruasdh
hmmm
got it