Reply
Thread Tools
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#81
Originally Posted by TNiga View Post
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
__________________
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
#82
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);
}
__________________
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
#83
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
__________________
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
#84
Hooray! Thanks to guys @ #qt I got it working. The code looks now like this:
http://www.pastie.org/1053508
__________________
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
#85
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
__________________
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: 353 | Thanked: 263 times | Joined on Dec 2009 @ Finland
#86
Originally Posted by D-Iivil View Post
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.
__________________
My Maemo5 projects:
mSpede - Speed testing game | Them Bloody Ducks - 2D duck hunting game | Maetronome - A simple metronome app | CuteMPC - MPD client
 
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#87
Originally Posted by TNiga View Post
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
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.
__________________
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: 353 | Thanked: 263 times | Joined on Dec 2009 @ Finland
#88
Originally Posted by D-Iivil View Post
I tried to use it but couldn't get it scrolling
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.
__________________
My Maemo5 projects:
mSpede - Speed testing game | Them Bloody Ducks - 2D duck hunting game | Maetronome - A simple metronome app | CuteMPC - MPD client

Last edited by TNiga; 2010-08-02 at 12:32.
 
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#89
Originally Posted by TNiga View Post
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.
__________________
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: 353 | Thanked: 263 times | Joined on Dec 2009 @ Finland
#90
Here's a little test I made on my PC and it scrolls fine.
Attached Files
File Type: zip scrollareaexample.zip (9.2 KB, 88 views)
__________________
My Maemo5 projects:
mSpede - Speed testing game | Them Bloody Ducks - 2D duck hunting game | Maetronome - A simple metronome app | CuteMPC - MPD client
 

The Following User Says Thank You to TNiga For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 09:36.