![]() |
Re: Need assistance from QT programmer
Quote:
#include <QtCore> #include <QMainWindow> #include <QProgressDialog> #include <QColorDialog> #include <QHash> #include <QFile> #include <QTextStream> But still have the errors. |
Re: Need assistance from QT programmer
Quote:
if (!file.open (IO_ReadOnly)) // didn't work QTextStream stream ( &file ); .... while( !stream.eof() ) { stream is only declared in the "if-block" scope. The same like this. if (!file.open (IO_ReadOnly)) QTextStream stream ( &file ); .... while( !stream.eof() ) { or if (!file.open (IO_ReadOnly)) { QTextStream stream ( &file ); } .... while( !stream.eof() ) { would produce an error :-) |
Re: Need assistance from QT programmer
Quote:
So I tried this: while( !stream.atEnd()) And got no errors. However the function does not work, I get nothing into QString called "oldfont1" when trying to do it like this: Code:
QFile file("/etc/hildon/theme/colors.config"); |
Re: Need assistance from QT programmer
Quote:
Code:
file.open(QFile::ReadOnly);Or does a QFile open the file directly after declaring it? I thought that.. if it's not opened, nothing is read, and the QString stays empty. |
Re: Need assistance from QT programmer
Quote:
I thought it opens the file automaticly, but obviously it didn't :) |
Re: Need assistance from QT programmer
Rule number one: look from API first. :)
Usually there are examples how to use the class, for example QFile. |
Re: Need assistance from QT programmer
Quote:
Problem (for me) is that most of the docs are written in the way that the writer assumes that reader already knows how things are working and therefore they are lacking the basic guides like: 1. create QFile "object" or what ever it's called 2. you must open the file with separate command so type file.open 3. do something with the file you just opened etc etc.... But I'm slowly learning and thanks to you guys for answering my questions over and over gain. |
Re: Need assistance from QT programmer
Quote:
Quote:
|
Re: Need assistance from QT programmer
Quote:
Anyways, it's now working and getting closer to first release :) |
Re: Need assistance from QT programmer
What do you not understand exactly?
In the example they don't use QTextStream::readLine(), they use QFile::readLine(), which is inherited from QIODevice. The difference is that QTextStream::readLine() returns a QString and QFile::readLine() returns a qint64 (QByteArray in the example), but I don't know anything about qint64 or QByteArrays, so I'll stick with QTextStrem::readLine() :p |
Re: Need assistance from QT programmer
Quote:
Anyways... next "problem" is to read gconf -values and since Qt Creator doesn't support it natively and documentation is really poor on that area, I think I'm gonna have no spare time problems this weekend... |
Re: Need assistance from QT programmer
Oh I'm sorry, I thought it was your current question, I read it wrong :p
But I'd also like to know that gconf thing :D I want to make an Install function in my Wallpaeper app, so people don't have to use the desktop settings anymore. This seems to be something about GTK+ for Qt, haven't read it, gotta go again :p http://ubuntuforums.org/showthread.php?t=1270124 |
Re: Need assistance from QT programmer
Quote:
http://maemo.gitorious.org/~vivainio...nf/gconfitem.h But once again I don't even know where to start with that. No matter what I write in the source I cannot make Qt Creator to build it... |
Re: Need assistance from QT programmer
That page is linked from:
http://wiki.forum.nokia.com/index.ph...pers_for_GConf The GConfItem looks like a great object to me, easy to use too, but I don't know what I should #include, maybe it needs another entry in the .pro file, just like QMaemo5InformationBox needs QT += maemo5.. The example on this page uses GConfItem: http://wiki.forum.nokia.com/index.ph...th_Qt_Mobility I've tried a few things, but Qt keeps telling me "GConfItem is not a type name" :( Can somebody please clarify this GConfItem object? :D |
Re: Need assistance from QT programmer
Have you added these lines to .pro file?
Code:
CONFIG += link_pkgconfig |
Re: Need assistance from QT programmer
Quote:
|
Re: Need assistance from QT programmer
Quote:
I also did a 'GConfItem' search on my NokiaQtSDK directory, but it found nothing. It does have some gconf headers that I can include, but even when I included all of them, it still doesn't recognise GConfItem :( The auto-complete feature of Qt Creator is a great way of seeing which headers can be included in this case :) Do I need to install some additional packages for the Nokia Qt SDK? Apparently this: http://maemo.gitorious.org/~vivainio/maemo-af/libgq-fremantle/blobs/master/gconf/gconfitem.h has to go into an include dir.. ? |
Re: Need assistance from QT programmer
http://maemo.org/packages/view/libgq-gconf-dev/
It wouldn't install on Windows, but we're getting close :p |
Re: Need assistance from QT programmer
Install lib in scratchbox armel target and make links of gconf lib and include files under usr and place them in NokiaQtSDK Maemo usr/lib and usr/include.
|
Re: Need assistance from QT programmer
Thanks, but I don't quite understand it..
I'm using Madde on a WinXP system, so I guess that makes things different? :p |
Re: Need assistance from QT programmer
Hi again guys.
I need some help with validating user input and then do actions based on if the input is valid or not. So far I'm good with validating the input, the validator allows me only to input correctly formatted stuff. What it doesn't check is if the input length is enough. What I don't know is how to know later if the input was long enough or not. Here's what I do when program launches (I create the validator and set it to line edits): Code:
Code:
void MainWindow::on_line_edit_font1_editingFinished() |
Re: Need assistance from QT programmer
Quote:
Code:
if (ui->line_edit_font1->text().length() == 7) {I don't know how this qtvalidator work, but isn't that enough to prevent the short text? regards Nicolai |
Re: Need assistance from QT programmer
Quote:
What I want to achieve is that when user has typed in less than seven digits and he jumps to next box, it would revert the box value back to what it was before user started to type the stuff in the box. That way I could prevent situation where the box has less than seven digits in it. |
Re: Need assistance from QT programmer
Quote:
Quote:
Code:
QRegExp regexer("^\\#[0-9a-fA-F]{6,6}$");(.. your characters ..) $ = until the end of the string Also, you might consider this: Code:
ui->line_edit_font1->setValidator(new QRegExpValidator(regexer, ui->line_edit_font1);Edit: this way, you don't have to make "actualvalidator". |
Re: Need assistance from QT programmer
Here's a screenshot of situation I wan't to avoid:
http://i4.aijaa.com/b/00298/6799969.png |
Re: Need assistance from QT programmer
Quote:
So maybe I need to do something with the validator? Tell validator to fill in the previous value if user didn't fill in all required digits? How? |
Re: Need assistance from QT programmer
Quote:
Quote:
|
Re: Need assistance from QT programmer
Maybe you can use void QLineEdit::editingFinished () signal.
This signal is emitted when the Return or Enter key is pressed or the line edit loses focus. Note that if there is a validator() or inputMask() set on the line edit and enter/return is pressed, the editingFinished() signal will only be emitted if the input follows the inputMask() and the validator() returns QValidator::Acceptable. The input is valid if the signal is emitted. |
Re: Need assistance from QT programmer
Quote:
|
Re: Need assistance from QT programmer
Is the behavrio different, if you use setInputMask instead
of a validator? http://doc.trolltech.com/4.7/qlineed...inputMask-prop ui->line_edit_font1->setInputMask("\#NNNNNN"); regards Nicolai |
Re: Need assistance from QT programmer
Wild idea. :D
Reimplement void QLineEdit::focusOutEvent ( QFocusEvent * e ) and check what QLineEdit::validator()::validate() returns. |
Re: Need assistance from QT programmer
So you want to revert to original value in the text lenght is < 7 ?
You can use focusInEvent to save the original text in a qstring and focusOutEvent to revert. |
Re: Need assistance from QT programmer
Quote:
|
Re: Need assistance from QT programmer
That is strange, btw my example was wrong. The format
for Hex-Digits is "HHHHHH". I am pretty sure this should work. But I can not try it out at the moment. Can you try again with the format: ui->line_edit_font1->setInputMask("HHHHHH"); |
Re: Need assistance from QT programmer
Quote:
|
Re: Need assistance from QT programmer
Quote:
|
Re: Need assistance from QT programmer
They aren't signals. They are virtual methods. You have to reimplement those methods to use them.
|
Re: Need assistance from QT programmer
I don't know how you can use this in Qt Designer, but you can use those methods like this:
mylineedit.h PHP Code:
PHP Code:
|
Re: Need assistance from QT programmer
Sorry for changing the subject, but the GConfItem problem still remains for both D-Livil and me..
Quote:
I've downloaded libgq-gconf-dev_0.2-3+0m5_armel.deb from the package page, Then I unpacked everything into: E:\NokiaQtSDK\Maemo\4.6.2\sysroots\fremantle-arm-sysroot-1030-slim\usr and added your suggestion to src.pro: Quote:
Copying doesn't seem like the right way to do it, but I'm clueless. ================================================== I did manage to include GConfItem by putting these files in my project, but those files also had their own includes, and it seemed endless to me. It wouldn't build because I don't have those headers. Another thing.. I see "#include <gconf/gconf.h>" here and there, but in my setup it's "#include <gconf/2/gconf/gconf.h>". I didn't change anything manually, just a straightforward Nokia Qt SDK install. The #include lines in those headers point to <gconf/....h>, so that's a dead end. I hope I don't bother anyone too much about this, but any help would be great |
Re: Need assistance from QT programmer
Well.. I think it's solved :D
Use system("command"); But be careful with system commands :D For instance, when you use Code:
system("gconftool-2 -R /apps/osso/hildon-desktop/views");Code:
current = 1I've been able to set backgrounds with the following: Code:
system('gconftool -s /apps/osso/hildon-desktop/views/1/bg-image -t string "/home/user/MyDocs/.images/abstract1_01.jpg"'); |
| All times are GMT. The time now is 17:44. |
vBulletin® Version 3.8.8