Hello can anyone tell me how can I open a specified folder in Qt?
Suppose in a lineEdit I define the folder path like
D:/MyFolder
Then how can i open this folder using push button?
What should I use for that?
You can use:
QDesktopServices::openUrl(QUrl::fromLocalFile(yourFolderPath));
inside a slot connected to you button.
Related
I'd like to show a virtual file system alongside the normal file system in a qml file dialog. For that virtual file system i will use a customized class derived from qfilesystemmodel.
However how can i tell the qml file dialog to use my custom model?
I have seen in the
qml/QtQuick/Dialogs/DefaultFileDialog.qml source code, that it has a modelComponent property but I don't know how to modify that property. Can anybody help? Is this even the right way to achieve it or should it be done in another way?
I am using Qt5 and having some problems in setting the back ground image of a QPushButton. I am using Qt Creator and Design to drag and drop the QPushButton. After that I created a source folder and placed an image in that directory and I googled and tried doing
ui->pushButton_play->setStyleSheet(QString::fromUtf8("background-image: url(:/source/play.png);"));
but no success...am I creating the folder in a wrong place?..I created in D:\Qt5_PROJECT_NAME\source or will I make the url(:\\source\\play.png). Nothing is working...please help...
Did you add the images file into .qrc file? A URL start with : has indicated that It will be searched in .qrc file. If .qrc file didn't used, URL should not start with :. Maybe you should access the image file as
ui->pushButton_play->setStyleSheet(QString::fromUtf8("background-image: url(source/play.png);"));
This is The Qt Resource System documentation.
Qt Creator give the possibility to attach some resource to the project.
I created in the project directory a folder called: Images. inside i have the file splash1.jpg
I created then the Resources file and attached the file as shown in the following figure:
Which is now the correct way to access from code such a file?
I tryed
QPixmap pixmap( "Images/splash1.jpg" );
QPixmap pixmap( "./Images/splash1.jpg" );
but none of them worked.
if i put just ./Images/splash1.jpg work at least if i compile by hand with qmake and make because has the correct path at runtime but no way to make it work within qt creator
Any idea??
Cheers,
Qt5 resources explains all you need. You have to put the colon before the path in the source tree. You also have placed a prefix, so :/Images/Images/splash1.jpg. This will give you a path.
If you need a URL, then use the qrc: scheme.
The correct way to load with Qt resources is: :/Images/Images/splash1.jpg.
What you could also do, is assign an alias to the resource. This way you don't need the .jpg: :/Images/splash
You can use ":/prefix/name of your image".
I have written a program on XCode4, how can I change the icon of the program?
Refer to the screen capture below:
Also, what is the size for the icon?
Thanks
You put icon file into Resources folder, and then open .plist file (also in resouces folder). Set icon file name in properties list.
I have a custom file type that I'm reading from and writing to within an AIR application. The file type is XML based but contains encoded data for an image. I've already defined the file type in my application manifest file using the tag which assigns a custom icon to the file.
What I'm trying to figure out is whether it's possible to set the icon for each individual file to be a preview of the image contained within.
there is nothing in the AIR sdk that will do this. it's up the operating system of your file to handle the file icons. i mean, you might be able to assign dynamically generated icons to that file, but you would have to create the icon, write it to your applicationStorageDirectory (ideally) and let your app assign the icon from there, assuming you could find a good way to dynamically change your app.xml file to point to your new icon file, which i don't believe is possible.
however, if your operating system can change your file icon, you can call native process on the file to handle the change this way.
for example, under Mac OS X, you can both automatically create and assign a new icon for an image file of the image contained in the file by writing the following command in Terminal:
$ sips -i FILE_NAME
therefore, if you deploy and AIR application for Mac OS X with a native installer, you can call that command on an image file using a Native Process.