Reply
Thread Tools
Posts: 180 | Thanked: 76 times | Joined on May 2010
#111
You can use member variable to access variables in other method.

MainWindow.h
Code:
class MainWindow
{
...
private:
    QStringList fonts;
}
MainWindow.cpp
Code:
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    progress("Setting up the theme, please wait...", "Abort", 0, 0, this),
    colors()
{
    ui->setupUi(this);
    ui->scrollArea->setWidget(ui->widget);
    readdirs();
    QString oldfont1 = ui->font1->text();
    QString oldfont2 = ui->font2->text();
    QString oldfont3 = ui->font3->text();
    QString oldfont4 = ui->font4->text();
    fonts.append(oldfont1);
    fonts.append(oldfont2);
    fonts.append(oldfont3);
    fonts.append(oldfont4);
//    readSettings();
}
Maybe change the method name to be more descriptive
Code:
void MainWindow::on_pushButton_clicked()
{
     fonts.at(0); //do something to oldfont1 string
}
 

The Following User Says Thank You to Diph For This Useful Post:
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#112
Originally Posted by Diph View Post
You can use member variable to access variables in other method.

MainWindow.h
Code:
class MainWindow
{
...
private:
    QStringList fonts;
}
MainWindow.cpp
Code:
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    progress("Setting up the theme, please wait...", "Abort", 0, 0, this),
    colors()
{
    ui->setupUi(this);
    ui->scrollArea->setWidget(ui->widget);
    readdirs();
    QString oldfont1 = ui->font1->text();
    QString oldfont2 = ui->font2->text();
    QString oldfont3 = ui->font3->text();
    QString oldfont4 = ui->font4->text();
    fonts.append(oldfont1);
    fonts.append(oldfont2);
    fonts.append(oldfont3);
    fonts.append(oldfont4);
//    readSettings();
}
Maybe change the method name to be more descriptive
Code:
void MainWindow::on_pushButton_clicked()
{
     fonts.at(0); //do something to oldfont1 string
}
That did the trick and learned something new also, thanks

Now I'm strugling with QColorDialog which seems to be buggy (don't know if it's my or Qt's fault); colors shown on the palette arent matching to the actual selected color (color shown at the box on the right). You can see on the screenshot attached that on the left box I'm choosing a green color and on the right box orange is shown (and selected).
Attached Images
 
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE
 
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#113
Originally Posted by D-Iivil View Post
Now I'm strugling with QColorDialog which seems to be buggy (don't know if it's my or Qt's fault); colors shown on the palette arent matching to the actual selected color (color shown at the box on the right). You can see on the screenshot attached that on the left box I'm choosing a green color and on the right box orange is shown (and selected).
http://bugreports.qt.nokia.com/browse/QTBUG-11788

Not your fault :-)

Nicolai
 
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#114
Originally Posted by nicolai View Post
http://bugreports.qt.nokia.com/browse/QTBUG-11788

Not your fault :-)

Nicolai
Oh, then I can stop figuring my way out of this :-D

Seems like they have fixed it in Qt 4.7, maybe I shall install it and see if it helps...

Edit: where the hell I can download 4.7 for Maemo? Or isn't it released yet?
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE

Last edited by d-iivil; 2010-09-22 at 12:10.
 
CepiPerez's Avatar
Posts: 1,023 | Thanked: 4,421 times | Joined on Feb 2010 @ Argentina
#115
It's ibqt4-experimental and it's in the repositories (don't know if it's in tresting, but I'mshure its in devel).
 
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#116
Originally Posted by CepiPerez View Post
It's ibqt4-experimental and it's in the repositories (don't know if it's in tresting, but I'mshure its in devel).
Hmm... there's plenty of packages starting with libqt4-experimental. Installing them all via apt-get won't work, I'm getting depency issues with package libqt4-experimental-dev:
Code:
The following packages have unmet dependencies:
  libqt4-experimental-dev: Depends: libgles2-sgx-img-dev but it is not installable
                           Depends: opengles-sgx-img-common-dev but it is not installable
                           Depends: libsqlite3-dev but it is not installable
Installing all other packages one by one doesn't sound like an option to me so I went and installed just the core, but that didn't fix the colordialog -issue...
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE
 
Posts: 180 | Thanked: 76 times | Joined on May 2010
#117
Are you sure you didn't install any other library than core and you compiled the app with Qt 4.7? I thought your app would at least need core and gui...
 
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#118
Originally Posted by Diph View Post
Are you sure you didn't install any other library than core and you compiled the app with Qt 4.7? I thought your app would at least need core and gui...
I installed core and gui (forgot to mention the gui in last post) and yes, I re-compiled the app with 4.7 Qt Creator.

Well, anyways, that's a bit offtopic issue and will hopefully be fixed in the future (the colordialog bug).

Tomorrow I'll try to get the parse-color-codes from file -thing working and release first devel version for public use
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE
 
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#119
Originally Posted by Diph View Post
Store the items in QHash. Then you can access items by key: QHash::value(const Key & key)

Code:
QFile file(/etc/hildon/theme/colors.config);
if (!file.open (IO_ReadOnly))
   // didn't work
QTextStream stream ( &file );
QString line;
QHash<QString, QString> variables;
while( !stream.eof() ) {
     line = stream.readLine();
     //Split
     QStringList splittedLine = line.split("=");
     //Maybe add some checks here (splittedLine.count == 2 etc.)
     variables.insert(splittedLine.at(0), splittedLine.at(1)); 
}
file.close();
Still need some help with this :-(

My code (mainwindow.cpp) looks now like this:
Code:
    QFile file("/etc/hildon/theme/colors.config");
    if (!file.open (IO_ReadOnly))
       // didn't work
    QTextStream stream ( &file );
    QString line;
    QHash<QString, QString> variables;
    while( !stream.eof() ) {
         line = stream.readLine();
         //Split
         QStringList splittedLine = line.split("=");
         //Maybe add some checks here (splittedLine.count == 2 etc.)
         variables.insert(splittedLine.at(0), splittedLine.at(1));
    }
    file.close();
    QString oldfont1 = variables.value(key.DefaultTextColor());
And build errors I get are:
'IO_ReadOnly' was not declared in this cope
'stream' was not declared in this scope
'key' was not declared in this scope

I propably didn't quite understand how QHash works so the last line of my code might be totally wrong too...
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE
 
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#120
Originally Posted by D-Iivil View Post
And build errors I get are:
'IO_ReadOnly' was not declared in this cope
Use QIODevice::ReadOnly instead.
Originally Posted by D-Iivil View Post
'stream' was not declared in this scope
maybe
#include <QTextStream>
Originally Posted by D-Iivil View Post
'key' was not declared in this scope
 
Reply


 
Forum Jump


All times are GMT. The time now is 15:31.