I'm coding a small and basic error tracker with Qt. The whole application is in a QTable.
Each error is linked to a file ; so, one of the columns of my table deals with that. I have a QLabel and a button next to it ; you click on the button to select a file, and then, the label displays the name of the file.
What I'd like to do now : the QLabel appears as a link, and when you click on it, it opens the file (with whatever app is associated to the file's extension). I'd rather it in the form of a link, because it's more obvious for the user. If I don't manage to do it, I'll go with a home QLabel herited class with a click signal, but it's not quite the same thing.
So, is what I want to do possible ?
And how would you do it ? Thanks in advance for your help !
You can use html in QLabel's text, so lets use that. Then set the QLabel to automatically open the link:
ui->label->setText("Link to file");
ui->label->setOpenExternalLinks(true);
Related
I am trying to set tab order by tab text or tab name
ui.tabWidget->setTabOrder(//set order here by tab name like "helloTab","hiTab");
//I have tried this(I know it's dumb just trying)
ui.tabWidget->setTabOrder(ui.tabWidget->tabBar->findChild<QTab *>("tab_1"), ui.tabWidget->tabBar->findChild<QTab *>("tab_2"));
Till now no hope of getting this done. I am fairly new to qt.
Any Ideas or help would be helpful.
QTab is not defined in Qt. Use QWidget:
ui.tabWidget->setTabOrder(ui.tabWidget->tabBar->findChild<QWidget *>("tab_1"), ui.tabWidget->tabBar->findChild<QWidget *>("tab_2"));
I'm working on a project that collects data from the project then displays it using xfdf to populate a .pdf file. Now when I use Chrome or Firefox it opens in a new tab which is exactly what I want, but some of my clients will be using IE, which opens it in the same window and causes some confusion. What area of the code should I be looking at in order to tackle and solve this problem?
I can show code examples, just let me know what I need to show.
Thanks,
Steve
Edit: When I click 'Print Application' button, it asks me to save or open the file. When they click open, it opens in the same tab, I want it to appear in a new tab.
In my experience, the best way to accomplish this is to alter your template linking to the PDF. For example:
Clicky!
This should work in all browsers.
Well. I'm working on an IDE. Some of you maybe saw a post about it.
Well, i have no clue of how QTreeWidget & QtreeWidgetItem works since can't find a demo and the documentation doesn't help.
Well, what i'm trying to do is a IDE that you open the project file and then include all the files of the project to the tree. (Files in the project file are included by doing #include "filename"). How i do this?
Then you click a file and open it in a Tab (That was on other question). So in this part i just need an example of how to do the file click. :)
A simple solution would be to directly use QTreeWidgetItem. For every file in your project, create an instance of QTreeWidgetItem:
QTreeWidgetItem *file = new QTreeWidgetItem(browserWidget);
file->setText(0, filename);
Where "filename" is a string containing the name of your file. You can get the filename by parsing your project file looking for lines beginning with "#include".
By passing another QTreeWidgetItem in the constructor of a new item, you make the new item a child of the othe one. That way you can create directory structures.
To open a file, you can connect to the signal "itemDoubleClicked" of the QTreeWidget. You will get a pointer to the clicked widget item. Calling "text()" will retrieve the filename. If you have a directory structure, you need to do this too for all parent widget items. By concatenating the strings, you will get the path to your file.
You can find an example for this in the Qt Docs (see file settingstree.cpp)
As long as your IDE stays simple, this will be sufficient. A more flexible and "object-oriented" solution would be to create a subclass of QTreeWidgetItem. You will need to overwrite some methods. Since you probably only need read-only access the four methods described in the Qt Docs will be enough.
Well, i'm working on an IDE System, which can open multiple files at same time. I'm somewhat noob with Tabs.
What i'm trying to do is a TabSystem, you click a file on the File Tree and it opens a new tab for it and show it's content. You can switch to other tag then switch to that one, drag tabs, etc.
Any idea?
To display your project tree you could use QTreeWidget. For file content you could use QTextEdit(for starter). Use QTabWidget to show multiple QTextEdits in different tabs.
We have a designer creating a user interface for an application. The main window has several QStackedWidgets used for in place panel switching. What I'd like to be able to do is extract each individual panel that makes up each page of the QStackedWidget into it its own .ui file.
Is there an easy way to accomplish this from within Qt Designer, or are there any other tools to help accomplish this task short of redesigning all of the panels in their own .ui files?
You can cut/paste each panel into a blank QWidget (created with File > New), and save these widgets in their own .ui file.
When you copy a widget(lets call it widgetA) that contains other widgets(calling them miniWidgets) then the miniWidgets should still be layed out. WidgetA still needs a relayout and in that case its very easy to add a layout since you can practically use any layout you want (i suggest vertical or horizontal). Just right click on the widget containing widgetA then select Layout->horizontal Layout and that should do the trick.
If there is more than one widget than needs relayout then you are not copying the panel correctly and should copy one that englobes more of the panel.