logo
IRC Archive / Freenode / #qt / 2010 / June / 05 / 2
rohanpm
dispraekailo: show code? (or at least explain "doesn't like it too much" :-)
dispraekailo
ugh I figured it out.. still getting used to this framework ;
I'm overlooking a lot of overloaded functions.
Skrot-
Can I overload the operator< for a class to use qSort() on a QList containing pointers of said class?
dispraekailo
rohanpm, I really hate that I make such silly mistakes despite doing some really awesome stuff :P
rohanpm
dispraekailo: it's OK, mistakes are good 90% of the time...
dispraekailo
haha
rohanpm
as long as the mistaker is not foolish :-)
dispraekailo
:3
rohanpm
Skrot-: not sure if that would work; using the qSort with the lessThan parameter is probably better
wahnfrieden
hi
dispraekailo
hi
wahnfrieden
How can I disable the button on macs that toggles the toolbar visibility?
the only information I could find for this suggested to disable/change the context menu for the toolbar in windows, which obviously wont work on mac
I'm using the unified toolbar and title mode
Elv13
how can I replace an utf8 character in a qstring, replace("\u2029","\n"); does nto work
wahnfrieden
ah, Qt::MacWindowToolBarButtonHint
pietro10
Elv13: try wrapping the strings in QString()
replace(QString("\u2029"),QString("\n"));
Elv13
pietro10: it is in a QString, I am calling QString::replace
pietro10
Elv13: read what I did
replace(QString("\u2029"),QString("\n"));
if that doesn't work
change all the QString() calls to QString::fromUtf8String or whatever the function's name is
rohanpm
Elv13: can you show code of your testcase? it's not clear to me what your input is...
for instance, it wouldn't surprise me if you meant "\\u2029", not "\u2029
"
Elv13
;
rohanpm:sure just use a QTextCursor, get the selection (::selectedText) and try to split the lines
rohanpm
you should write a simple testcase which doesn't use a UI...
Elv13
according to the doc, I have to replace the unicode caracter by a \n to make it work
rohanpm
then you'll be able to focus on just getting this one thing right
Elv13
rohanpm: The Qt doc say this will happen, and that I need to do that to fix it, see http://doc.trolltech.com/4.6/qtextcursor.html#selectedText
rohanpm
Elv13: ok, the point is that I think you may be constructing your "U+2029" character wrongly
Elv13
so how can I construct it right?
rohanpm
well, if you write a simple testcase, it should be pretty easy to figure that out with a little trial and error :-)
Elv13
rohanpm: My test case it quite simple, convert a Textcursor selection to an array of lines, it can not be more simple
pietro10: Your solution does not work, toAscii() return a bunch of ???? instead of the utf8 character
pietro10
ok
I dunno then
aep
who said toAscii returns utf8 ?
it returns ascii
Elv13
I hope it does not ;), @pietro10 thanks
aep: and replace utf character by ????
aep
yes. everything not ascii is replaced
or even undefined i think
Elv13
aep: do you have an idea how can I convert utf8 linebreak to \n for a QTextStream or QString::split to handle it?
aep
whats an utf8 linebreak?
Elv13
aep: \n, but in UTF8, so it does not have the linebreak problem of ascii (\n on unix, \r on OSX and \n\r on windows)
aep
NEL ?
rdancer
rohanpm: what is the right way to cast it?
aep
who had that retarded idea. now we have 6 newlines
rohanpm
rdancer: qobject_cast
Elv13
this is my problem
rohanpm
rdancer: better to refactor the code to not need that, though (trivial in your example, but I imagine your real code is different...)
dispraekailo
How should I be accessing widgets in the .ui file from within the corresponding .h/.cpp files?
rdancer
rohanpm: as in using a variable for the layout?
aep
Elv13: qt doesnt offer what you need.
Elv13
dispraekailo: by extending the class generated by your .ui
dispraekailo
I'm not quite sure how I'm supposed to be retrieving them; they don't resolve as members by the names I gave them in the .ui file
aep
theres some unicode libs around that can convert stuff into sanity
dispraekailo
elaborate Elv13
Elv13
aep: http://doc.trolltech.com/4.6/qtextcursor.html#selectedText Qt cause the problem and say .replace should work
rohanpm
rdancer: no... just don't "lose" the pointer to the real type until after you don't need it any more...
Elv13
dispraekailo: extend the class generated by your .ui, the object names are going to be accessible as member variables
dispraekailo
Elv13, you're saying I should extend the Ui::<classname> instead of the one I already defined?
Elv13
dispraekailo: you can extend as many class as you want in C++
dispraekailo
Elv13, countless tutorials I've seen simply make a class extending some base widget, then have a Ui::<derivedClass> defined as well.. then in the constructor use the ui( new Ui::<derivedclass>) and ui->setupUi(this)
Right I just didn't think that was an appropriate paradigm considering how many examples I've seen like this.
Elv13
that work too
dispraekailo
Apparently not.
Or I'm setting up my stuff in the .ui file wrong.
rdancer
rohanpm: like this?: http://pastebin.com/K3F4W0Yb
Elv13
setupUI? yes it does work
dispraekailo
Elv13, yes it makes it look like the .ui file fine, but it doesn't give me access to any members
rohanpm
rdancer: sure... though it may be more efficient to setLayout only at the end
Elv13
dispraekailo: look at the .h generated by qmake/cmake and see the API it created
rdancer
rohanpm: addQuestions() is uses this->layout->addWidget()
dispraekailo
Elv13, it's in there. Not showing up in my derived class.
Elv13
dispraekailo: what are you deriving? If you use an object to represent your .ui, then you have to access them using that object, not from this->, to use this->, you have to extend the .ui
I think you are mixing the two way and got confused
rdancer
rohanpm: I feel like I'm doing it wrong -- is it correct to be adding child widgets to the layout as opposed to the widget itself?
dispraekailo
Ahhh I didn't consider accessing it through the ui->
Nice, thanks :)
Elv13
no problem
dispraekailo
I've never seen a construct like that in c++ before
Elv13
dispraekailo: it is easier to extend the ui than using a variable
dispraekailo
with a virtual member in the header, polymorphism with an external .h file, then using the external file as such :)
elaborate
kizzx21
hey guys, is there a way tell QWebFrame::print() to use the normal screen stylesheet instead of the print stylesheet?
* QWebFrame :: print()
dispraekailo
Does anyone know why setting a fileSystemModel's rootpath to QDir::currentPath() would cause the application to crash? I've verified that the path is legit,and I'm using that same path elsewhere without problem.
correction, it's crashing on the treeview->setModel( .. )
ugh I'm tired ;
stupid mistakes again
rohanpm
rdancer: yes it is
ryanevans
how can i select each row in a QTableWidget, when i clicked any cell ?
JohnFlux
Has anyone found a way to add images to tooltips?
Specifically, a QImage or QPixmap
I asked.. 4 years ago and at that time was told to wait for Qt4.3 ;-)
how time flies
zeke
JohnFlux: what about something like this? http://lists.trolltech.com/qt-interest/2004-08/thread01069-0.html
it's 6 years old but maybe still works the same?
http://doc.trolltech.com/4.6/qmimesource.html
JohnFlux
zeke: sweet
zeke: that's exactly what I want
zeke
:>
wait
class is obsolete
xD
JohnFlux
haha
zeke
you can probably use QMimeData
blah
JohnFlux
yeah it's also now called Q3MimeSourceFactory
zeke
all I am finding is how to do it in Qt3
xD
ryanevans
how can i setstylesheet to the qtablewidget ? it doesn't work.
sorry, it works :x
Znurre
Hello everyone, I have some problems with QtScript. I created a small sample code to showcase my issue. If someone would take a quick look at this code and tell me if this is even possible, I would be very grateful: http://pastebay.com/102183
kizzx2
hey guys, is there a way tell QWebFrame :: print() to use the normal screen stylesheet instead of the print stylesheet?
mta`chrono
does anyone know how to hide the title of a widget?
Znurre
mta`chrono: what title do you mean? got any example?
mta`chrono
Znurre: if you create a widget/qdialog under normal circumstances it has got a window title bar at the top (like every window has). I would like to hide this.
Znurre
check the Qt::FramelessWindowHint
widget->setWindowFlags( Qt::FramelessWindowHint );
mta`chrono
Znurre: thank you very much!!!!
Znurre
no problem! :)
extreme001
hi
after learning c++ in school i want to get in gui-apps and want to use qt
but there's a thing i don't understand...i never had to worry about licenses and qt has more than one (right?)?
can i sell my software i coded with qt without charging any fees to qt/nokia ?
is that right ?
Znurre
extreme001: as far as I understand it, you can now release commercial non-opensource applications without charging any fees to Nokia as long as your application is linked dynamically and no changes to the Qt source has been made
extreme001
dynamically?
oh i have to put the dlls in my app ?
and no change to qt toolkit self?
Znurre
yes, atleast this is how I understood it, I am not very good with licenses myself but since noone else here replied I try to help you the best I can :)
extreme001: see this: http://en.wikipedia.org/wiki/Static_linking
extreme001
ah ok...
i have to use the dlls, that's all
thank you very much
Znurre
yeah
no problem
extreme001
first c++ gui app starts... :D
Znurre
I wish you good luck :)
feel free to ask me if you run into any problems
Sjors
so, let's see if my patch to Qt applies to trunk, if so, I'll submit it on the tracker
or is there a better place?
the patch adds custom icons for Growl notifications and possibly others in the future
jpnurmi
Sjors: qt.gitorious.org :)
!f contrib
qtassistant
jpnurmi: [contribute] http://qt.gitorious.org/qt/pages/QtContributionGuidelines
Sjors
thanks jpnurmi
jpnurmi
np
passito
Hello, i have a question about QNetworkAccessManager
what is the proper way to handle a download with this class ?
http://pastebin.com/TUKuHkT2 <-- I am doing right ?
Znurre
since the finished() signal passes a pointer to the QNetworkReply object, you can just connect this to a slot and handle the reading there, atleast that's how I use to do it
Sjors
jpnurmi: would it be best to provide patches for 4.6, 4.7 and master, 4.7 and master, or just master?
pumphaus
passito: no. you need to create a custom slot for the finished(QNetworkReply*) signal and read from the reply there
passito
okay, and about the error handling ?
timeout, etc
pumphaus
passito
w.out this, if a query is not valid (fake proxy, etc) ... it timeouts after more than 1 min.
thanks
jpnurmi
Sjors: i'd go with master and let Trolls to decide whether to backport the bugfix
Sjors
jpnurmi: it's not a bugfix :)
jpnurmi: it adds a feature
to QSystemTrayIcon :)
jpnurmi
Sjors: does it affect public api? if so, it goes to master :)
Sjors
jpnurmi: it adds two methods to public api :)
jpnurmi
it might be hard to get new stuff to 4.7 anymore
Sjors
oh and it adds an enum value
i.e. it only adds new stuff, doesn't change existing
jpnurmi
ok, then master definitely
Sjors
allright
that means the new feature will only be in qt 4.8? o_O
gnusar
is there a way to check if keys on the keyboard are being pressed? i dont want to receive keyevents but check every frame.
Znurre
I have some problems with QtScript, and passing a pointer to the script. I created a small sample code to showcase my issue. If someone would take a quick look at this code and tell me if this is even possible, I would be very grateful: http://pastebay.com/102183
passito
okay so, if I want to handle properly a qnetworkreply, i have to use the readyRead signal, and the waitForReadyRead method to specify the timeout value ?
Znurre
passito: waitForReadyRead is a blocking function, and has nothing to do with the readyRead signal
it will return true when there is data to read, if you want to implement your own event loop
passito
y i've seen that, sorry
Znurre
I will write a small example code for you, to show you how I would do it
passito
how can I specify a timeout value so that it will send a error(QNetworkReply::NetworkError) signal to the reply ?
okay znurre :)
Znurre
passito: http://pastebay.com/102198
something like that
you would ofcourse have to define the new slots in your header file too
passito
okay I see
i'm going to try that
Znurre
:)
good luck, and feel free to ask me if you run into any problems
passito
i'm just wondering
with this code, i can't display a progress bar for the download ?
Znurre
true
passito
i'd have to use ready read
ecko
does qt declarative have an equivalent of a QGroupBox?
passito
and handle the progression by myself ?
Znurre
passito: then you would need to use downloadProgress ( qint64 bytesReceived, qint64 bytesTotal ) signal in QNetworkReply