Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    Need assistance from QT programmer

    Reply
    Page 12 of 18 | Prev | 2   10     11   12   13     14   | Next | Last
    Diph | # 111 | 2010-09-22, 10:23 | Report

    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
    }

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to Diph For This Useful Post:
    d-iivil

     
    d-iivil | # 112 | 2010-09-22, 11:17 | Report

    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).

    Edit | Forward | Quote | Quick Reply | Thanks
    Attached Images
     

     
    nicolai | # 113 | 2010-09-22, 11:33 | Report

    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

    Edit | Forward | Quote | Quick Reply | Thanks

     
    d-iivil | # 114 | 2010-09-22, 12:03 | Report

    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?

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by d-iivil; 2010-09-22 at 12:10.

     
    CepiPerez | # 115 | 2010-09-22, 12:23 | Report

    It's ibqt4-experimental and it's in the repositories (don't know if it's in tresting, but I'mshure its in devel).

    Edit | Forward | Quote | Quick Reply | Thanks

     
    d-iivil | # 116 | 2010-09-22, 12:59 | Report

    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...

    Edit | Forward | Quote | Quick Reply | Thanks

     
    Diph | # 117 | 2010-09-22, 15:13 | Report

    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...

    Edit | Forward | Quote | Quick Reply | Thanks

     
    d-iivil | # 118 | 2010-09-22, 17:24 | Report

    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

    Edit | Forward | Quote | Quick Reply | Thanks

     
    d-iivil | # 119 | 2010-09-23, 10:47 | Report

    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...

    Edit | Forward | Quote | Quick Reply | Thanks

     
    nicolai | # 120 | 2010-09-23, 10:55 | Report

    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

    Edit | Forward | Quote | Quick Reply | Thanks

     
    Page 12 of 18 | Prev | 2   10     11   12   13     14   | Next | Last
vBulletin® Version 3.8.8
Normal Logout