You are not logged in.

1

Saturday, January 28th 2012, 9:20am

some questions related qtabwidget

i am creating a text editor with multiple tabs so i am using
qtabwidget
but i can create or add tabs but i am adding a textedit with each tab
bu i can get control to tabs but how to get control to textedits of a particular secodnly
for each tab i want to store multiple info for each file so i can have arrays of qstrings
but i want is:
info for each tab mutiple and mutiple tabs i hope you got it
thanks

2

Saturday, January 28th 2012, 10:31am

you can make your own widget that contains a textedit, and also contains some information about your strings.

e.g.:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
MyWidget : public QWidget
{
Q_OBJECT

public:
MyWidget(QTextEdit* te, QWidget* parent = 0);

QTextEdit* textEdit() {return m_te;}
void saveString(QString str) {m_strList << str;}
QList<QString> stringList(){return m_strList;}


private:
QList<QString> m_strList
QTextEdit* m_te;
};

if you add instances of those widgets to your tab widget, then you can access the QTextEdit from it, and you can see how you can save information and see what is stored.

just a quick example - the design is not too great, but something to get you started.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

3

Saturday, January 28th 2012, 12:23pm

thanks man
i have tried to understood that but i got my first anwser from here:
http://www.qtcentre.org/threads/34146-ac…from-QTabWidget
my second question is when we opena file using software like file managers how di get such singals
3 is when the text editor is on some one open file with it uing any software like filemanager i want it to do a function but dont want to open a new window how will i do that firefox and many softwares does that

4

Saturday, January 28th 2012, 1:05pm

what do you mean by file managers?

You can get signals when directory or file CHANGES, using http://developer.qt.nokia.com/doc/qt-4.8…temwatcher.html. But I'm not sure if that is what you mean by getting signals from file managers?

You can open files by letting the user select a file from a dialog - I think this is what you are after http://developer.qt.nokia.com/doc/qt-4.8/qfiledialog.html ? - there is a pic near the bottom.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

5

Sunday, January 29th 2012, 4:58am

thanks man for the filesystemwatcher it will be usefull i know about qfiledialog but i want
when you open a file browser and open file it opens using a file browser how to i get these signals
file borwser menas throught which we browse directories and files and edit it it providees agui interface to do that for eg. that omes default in windows
or in ubuntu naulties , dolphin , thumbar , etc.

6

Sunday, January 29th 2012, 10:43am

I'm not sure if there are messages for that. I have no idea about linux, there may be something in windows, but you will have to look directly at win messages

http://www.autohotkey.com/docs/misc/SendMessageList.htm
I didnt see any message there after a quick scan.

To me, I think those windows are shell windows - file browser could be any software that browses files, but you seem to be specifically interested in the O/S's windows.

Quoted

3 is when the text editor is on some one open file with it uing any software like filemanager i want it to do a function but dont want to open a new window how will i do that firefox and many softwares does that

firefox does not do something to a file if it is not already running! You run firefox, firefox opens a filedialog, like you know about. The dialog returns a file path, and firefox does something with the path.

You run your program, use a Qfiledialog, open the file with your text editor. Isn't that what you want?
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

7

Sunday, January 29th 2012, 12:33pm

that not i want
i was saying that if firefox is opened and when you opena url using a chat cleint firefox creates a new tab

8

Sunday, January 29th 2012, 2:40pm

thats because the O/S has 'registered' firefox as the default browser for html. If you want to open your software when you double click a file/select it in a file dialog, you have to make it the default program for that file type.

e.g. in win 7, right-click on a file -> open with -> choose default program.

then the next time you double-click a file, the O/S will pass the filename as an argument to your software. This is nothing at all to do with Qt.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

9

Monday, January 30th 2012, 9:22am

i know that how to my software get these signals it is not like that if i will open file throught my software it will automatically do a task to it i have to tell the task and that is my question is there any qt class for it

10

Monday, January 30th 2012, 1:02pm

Your English is too broken, I cant understand. Please try to use sentences properly.

"i have to tell the task and that is my question is there any qt class for it"
I dont know what you mean by 'tell the task'.


1. open the file/load the data
2. do the task on the data.

where are you stuck?
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

This post has been edited 1 times, last edit by "Amleto" (Jan 30th 2012, 1:07pm)


pitonyak

Trainee

  • "pitonyak" is male

Posts: 57

Location: Columbus, Ohio, USA

  • Send private message

11

Monday, January 30th 2012, 8:20pm

I believe that he is asking if QT implements a way to set file associations for the operating system so that it will cause his program to be called by the OS as the default action. His question may be slightly more involved than that (like maybe he only cares about the one file that he is currently editing), but that is just a guess.

12

Tuesday, January 31st 2012, 12:26am

if that is so, I don't think I will be too far wrong by saying there is no qt class that will modify win registry. I don't know how similar things work on Linux & Mac
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

13

Tuesday, January 31st 2012, 9:18am

my question is a bit complicated
how i tell you
how you generally open file
we open a file browser and click on any file to open it
now the software is opened
that means we have send some signals to the softwares ho do i gt these signlas i hope you got what i meant to say

14

Tuesday, January 31st 2012, 11:55am

when your software is opened, the only thing you get are command arguments -

int main(int argc, char** argv) //<-- argc, and argv are your only signals.
{}

you must use the data from argc & argv to run your code in the correct way.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

15

Tuesday, January 31st 2012, 12:09pm

thanks man can you tell me how to proprly use
argc, and argv are your only signals.
how to understand their signals and how to use their data

16

Tuesday, January 31st 2012, 1:38pm

argv is an array of strings, and argc says how many strings there are.

e.g. your program is at c:\test\program.exe. In a console you type:

>program.exe one two -g

if you debug, you will see in int main(int argc, char**argv)

argc = 4
argv[0] = "c:\test\program.exe"
argv[1] = "one"
argv[2] = "two"
argv[3] = "-g"

argv[0] is always the full path to the program.

I think if you program is used to open another type of file, e.g. .txt file, then this will happen:

argc = 2
argv[0] = "c:\test\program.exe"
argv[1] = "c:\the_file_that_you_chose.txt"

you can test what arguments you get with a loop:

Source code

1
2
3
4
5
6
#include <iostream>
int main(int argc, char*[] argv)
{
for (int i = 0; i < argc; ++i)
  std::cout << argv[i] << " ";
}
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

17

Wednesday, February 1st 2012, 9:34am

thanks i have got my solution it really helped

18

Wednesday, February 1st 2012, 11:25am

great!
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Used tags

QTabWidget