Installation and getting started with first app



  • Your problem lies more in the beginning of your build output:

    @
    ..\IDT_Demo_UI/idt_mainwindow.h:4:30: error: QSystemStorageInfo: No such file or directory
    @

    where does QSystemStorageInfo come from?

    If I googled correctly, it's part of QtMobility, did you install that? did you add the needed include paths in the pro file?



  • ok...then which class should i use to get the system storage info if it is for desktop application ?



  • Afaik QtMobility may also be used on the Desktop. But you have to set your include paths.



  • please guide me how to set that ...



  • I said Afaik, not that I did it before ;-)

    I never used QtMobility



  • [quote author="Thomas Kennedy" date="1301490967"]ok...then which class should i use to get the system storage info if it is for desktop application ?[/quote]

    I don't know what info you want to get from QSystemStorageInfo, but maybe "QDesktopServices::storageLocation() ":http://doc.qt.nokia.com/4.7/qdesktopservices.html#storageLocation provides what you need.


  • Moderators

    In order to use the QSystemStorageInfo class from Mobility, be sure that in your .pro file you have included the lines

    @
    CONFIG += mobility
    MOBILITY += systeminfo
    @



  • Thanks a lot...

    without changing .pro file I am trying with QDir::Drives()..I will update you soon about my results..before that I have another query...

    I have placed my controls on the main window by opening 'mainwindow.ui' in design mode..how would I create control variables for those controls in my code using QTCreator ?



  • "control variables"? You mean you need a pointer to them?

    @
    m_ui->myCoolLineEdit->setText("I'm so cool!");
    @

    works for me. myCoolLineEdit is of course the name you gave the widget in Designer, and m_ui is the member variable that holds the UI class you created.



  • excellent..now i understood this part Andre..I have creaed a QTreeWidget on my MainWindow and coded like tihs..

    @
    ui->treeWidgetDrives = new QTreeWidget();
    ui->treeWidgetDrives->setColumnCount(1);
    QStringList strlstHeaders;
    strlstHeaders<<tr("Storage Drives");
    ui->treeWidgetDrives->setHeaderLabels(strlstHeaders);
    @

    ...when i run my code nothing is happened to my TreeWidget(no header is assigned)..instead it is showing the properties which i set from 'Edit Tree Widget' dialog !!!

    [EDIT: code formatting, please use @-tags, Volker]



  • The tree widget is automatically created for you. Just remove the first line of your snippet.



  • if i remove that line and run the code I am not getting my Window displayed and here is the ouput..

    Starting E:\Bose\Qt playground\IDT_Demo_UI-build-desktop\debug\IDT_Demo_UI.exe...
    E:\Bose\Qt playground\IDT_Demo_UI-build-desktop\debug\IDT_Demo_UI.exe exited with code -1073741819



  • code -1073741819 = 0xC0000005. On windows this means an access violation. Seems like your UI is not initialized properly or messed up in some way....



  • perfect analysis..

    I have moved this line to bottom of the code like this..

    @
    IDT_MainWindow::IDT_MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::IDT_MainWindow)

    {
    // my code here...

        ui->setupUi(this);
    

    }
    @

    now i moved it to top and works fine..thanks a ton

    [EDIT: code formatting, please use @-tags or the editor button, Volker]



  • only one child item is being shown to my TreeWidget..please look into my code and lemme know where I went wrong !!

    @IDT_MainWindow::IDT_MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::IDT_MainWindow)

    {
    ui->setupUi(this);

    ui->treeWidgetDrives->setColumnCount(1);
    QStringList strlstHeaders;
    strlstHeaders<<tr("Storage Drives");
    ui->treeWidgetDrives->setHeaderLabels(strlstHeaders);
    
    SetupTreeItems();
    

    }
    void IDT_MainWindow::SetupTreeItems()
    {
    QTreeWidgetItem *treeItems = new QTreeWidgetItem(ui->treeWidgetDrives);
    treeItems->setText(0,tr("SystemDrives"));
    QTreeWidgetItem *treeChildItems = new QTreeWidgetItem(treeItems);
    QDir dir;
    dir.setFilter(QDir::Drives);

    QFileInfoList roots = dir.drives();
    
    for(int i=0 ; i<roots.count() ; ++i)
    {
        QFileInfo fiDrives = roots.at(i);
        QString strDrive = fiDrives.absoluteFilePath();
        treeChildItems->setText(i,strDrive);
    }
    

    }@



  • You must create a new item in your loop. You just overwrite the on you have in each iteration.



  • Your loop keeps on updating the text of the same tree item. Do you really expect to see more of them then?



  • you mean like this ??

    @for(int i=0 ; i<roots.count() ; ++i)
    {
    treeChildItems = new QTreeWidgetItem(treeItems);
    QFileInfo fiDrives = roots.at(i);
    QString strDrive = fiDrives.absoluteFilePath();
    treeChildItems->setText(i,strDrive);
    }@



  • [quote author="Thomas Kennedy" date="1301584395"]you mean like this ??

    @for(int i=0 ; i<roots.count() ; ++i)
    {
    treeChildItems = new QTreeWidgetItem(treeItems);
    QFileInfo fiDrives = roots.at(i);
    QString strDrive = fiDrives.absoluteFilePath();
    treeChildItems->setText(i,strDrive);
    }@
    [/quote]

    You can try it to get the answer :-)



  • tried...it added an 'empty item' at 0th position,and 'c:' at 1st..and no more :-(



  • So... you need to aquire some debugging skills... Just try to follow what happens in your code. Don't guess: measure instead. Try for instance to insert statements like this at every relevant point in your function, and look at the output:

    @
    qDebug() << LINE;
    @



  • :-)) ok..will do that..



  • Of course you must have an empty first entry, because you create this one outside your loop (line 21 in your original code snippet).

    This is the compactified working version:

    @
    void FancyClass::populate() {
    ui->treeWidget->setColumnCount(1);
    QStringList headers;
    headers << "Storage Device";
    ui->treeWidget->setHeaderLabels(headers);

    QTreeWidgetItem *rootItem = new QTreeWidgetItem(ui->treeWidget);
    rootItem->setText(0, "SystemDevice");
    
    foreach(QFileInfo drive, QDir::drives()) {
        QTreeWidgetItem *driveItem = new QTreeWidgetItem(rootItem);
        driveItem->setText(0, drive.absoluteFilePath());
    }
    

    }
    @



  • /me is thinking that instead of building a tree like that himself, he would use a QFileSystemModel instead...



  • thanks a lot...I will try with QFileSystemModel too..



  • "The program can't start because mingwm10.dll is missing from your computer.Try reinstalling the program to fix this problem."

    ..i am getting this error when i tried running my application in stand alone mode...any help ??



  • YOu are startin g without QtCreator, right?

    Did you try to search the forum for answers?

    see this "post":http://developer.qt.nokia.com/forums/viewthread/4869



  • yes Gerolf..I searched..everybody says that we need to set the invironment varioables..I did that too but of no use..



  • put the needed dlls beside your exe or set the PATH environment variable to contain the path to mingw10.dll.



  • I have set the PATH environment variable..but it says QtCode4.dll is missing !!



  • QtCode4? what's this? or do you mean QtCore4.dll?
    Then the path to this dll is miossinmg :-)
    You have to add it also.



  • sorry..that was typo..QtCore4.dll is correct..but where will this DLL reside ?



  • you find it inside your Qt installation
    depends which version you installed
    In Qt SDK with Qt 4.7.2, look here:

    <QtSDK Dir>\Desktop\Qt\4.7.2\mingw\bin



  • excellent Gerolf..it is working now..but my icons on buttons and Toolbar are missing in standalone application..



  • How did you add them?
    using from the file system or add them to a qrc file?



  • [quote author="Thomas Kennedy" date="1301650049"]excellent Gerolf..it is working now..but my icons on buttons and Toolbar are missing in standalone application..[/quote]

    Could be some missing image format plugins. Please look in the forum search for "imageformats plugins", it was discussed recently with some hints about how to resolve this issue.



  • yep...now I understood how to create .qrc file..many thanks..



  • i have 7 strings with me..I would like to show them in a text editor line by line...how would i do that ??



  • I have used Insert() method to do that..thanks for no reply :-)



  • now I am showing all my available drives in my Tree widget and upon selection am able to display the total/free size of the drive. Now I want to implement two things..

    1.load icons depending upon the drive type in my tree widget
    2.if it is CD-ROM drive disable the user section

    could somebody guide me on this !!!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.