View Single 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