maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Need assistance from QT programmer (https://talk.maemo.org/showthread.php?t=58569)

d-iivil 2010-07-20 15:52

Re: Need assistance from QT programmer
 
Quote:

Originally Posted by TNiga (Post 758015)
You can use QSettings class for that. Just add following functions to your MainWindow class:
Code:

void MainWindow::saveSettings() const {
    QSettings sett("blackplastic-theme/config");
    sett.setValue("font", text_of_combobox /* you now how to get that already */);
    // Other values like that also
}
void MainWindow::loadSettings() {
    QSettings sett("blackplastic-theme/config");
    bool bOK;
    QString font = sett.value("font", QVariant("")).toString();
    // Other values likewise and set comboboxes to show values
}

Then call loadSettings at the end of MainWindow's constructor and saveSettings in MainWindows's destructor (~MainWindow).

EDIT: QSettings saves config files under ~/.config so in this case config file would be ~/.config/blackplastic-theme/config

Thansk! That looks pretty straight forwarding even to me :)

d-iivil 2010-07-21 09:29

Re: Need assistance from QT programmer
 
Could you kindly tell me how to set the comboboxes show the value I want?

I tried all kinds of stuff but couldn't find how to do it right. Here's what I've tried so far and I'm getting build error " classQComboBox has no member named 'setCurrentText'
Code:

void MainWindow::writeSettings()
{
    QSettings sett("blackplastic-theme/config");
    sett.setValue("color", ui->Color->currentText());
    sett.setValue("transitions", ui->Transition->currentText());
}

void MainWindow::readSettings()
{
    QSettings sett("blackplastic-theme/config");
//    bool OK;
    QString color = sett.value("color", QVariant("")).toString();
    QString transitions = sett.value("transitions", QVariant("")).toString();
    ui->Color->setCurrentText(color);
    ui->Transition->setCurrentText(transitions);
}


d-iivil 2010-07-21 10:40

Re: Need assistance from QT programmer
 
Okay, got the errors cleared out of building process, but the comboboxes still shows the first item in the combobox as active one when launching the program. My code looks now like this:
http://www.pastie.org/1053465

d-iivil 2010-07-21 11:34

Re: Need assistance from QT programmer
 
Hooray! Thanks to guys @ #qt I got it working. The code looks now like this:
http://www.pastie.org/1053508

d-iivil 2010-08-02 09:58

Re: Need assistance from QT programmer
 
Once again I need to ask for some assistance :P

Now I've ran out of space on my program and I'd like to expand the content area and make it scrollable (kinetic scrolling with finger). I found this, but cannot find that widget (QAbstractScrollArea) from QT Creator:
http://wiki.maemo.org/Qt/Finger_Scrolling

TNiga 2010-08-02 10:47

Re: Need assistance from QT programmer
 
Quote:

Originally Posted by D-Iivil (Post 772859)
Once again I need to ask for some assistance :P

Now I've ran out of space on my program and I'd like to expand the content area and make it scrollable (kinetic scrolling with finger). I found this, but cannot find that widget (QAbstractScrollArea) from QT Creator:
http://wiki.maemo.org/Qt/Finger_Scrolling

I think you can use QScrollArea (which should be available in Designer, named Scroll Area) instead of QAbstractScrollArea.

d-iivil 2010-08-02 12:22

Re: Need assistance from QT programmer
 
Quote:

Originally Posted by TNiga (Post 772915)
I think you can use QScrollArea (which should be available in Designer, named Scroll Area) instead of QAbstractScrollArea.

I tried to use it but couldn't get it scrolling :D
I dragged the scrollarea to mainwindow, resized it to fill almost the whole mainwindow and then cut + pasted my elements inside of it, but the damn area won't scroll even the elements goes below the scrollarea. I also tried to scretch the scrollarea to be longer than my mainwindow but still didn't scroll.

TNiga 2010-08-02 12:28

Re: Need assistance from QT programmer
 
Quote:

Originally Posted by D-Iivil (Post 772991)
I tried to use it but couldn't get it scrolling :D
I dragged the scrollarea to mainwindow, resized it to fill almost the whole mainwindow and then cut + pasted my elements inside of it, but the damn area won't scroll even the elements goes below the scrollarea. I also tried to scretch the scrollarea to be longer than my mainwindow but still didn't scroll.

I haven't used scrollarea myself never, but according to Qt's manual I think you need to insert an empty widget in the scroll area and your other elements in the widget and then in MainWindow's constructor do this:
Code:

ui->yourScrollArea->setWidget(ui->yourWidget);
EDIT: Seems you need to put the widget outside the scrollarea in designer, otherwise it won't work.

d-iivil 2010-08-02 12:32

Re: Need assistance from QT programmer
 
Quote:

Originally Posted by TNiga (Post 772998)
I haven't used scrollarea myself never, but according to Qt's manual I think you need to insert an empty widget in the scroll area and your other elements in the widget and then in MainWindow's constructor do this:
Code:

ui->yourScrollArea->setWidget(yourWidget);

Actually the designer did that for me automaticly and I pasted my items inside that widget. Well.. need to find some example project and try to learn from it.

TNiga 2010-08-02 12:35

Re: Need assistance from QT programmer
 
1 Attachment(s)
Here's a little test I made on my PC and it scrolls fine.


All times are GMT. The time now is 02:23.

vBulletin® Version 3.8.8