qt4

pdf viewer for pyqt4 application?

天大地大妈咪最大 提交于 2019-12-09 15:59:17
问题 I'm writing a Python+Qt4 application that would ideally need to pop up a window every once in a while, to display pdf documents and allow very basic operations, namely scrolling through the different pages and printing the document. I've found the reportLab to create pdf files, but nothing about pdf viewers. Does anyone knows anything that might help. i was really hoping for the existence of something like the QWebView widget... thanks in advance to all 回答1: You can use the Poppler library

QFileDialog: adding extension automatically when saving file?

丶灬走出姿态 提交于 2019-12-09 15:00:18
问题 When using a QFileDialog to save a file and to specify the extension (like *.pdf) and the user types in a name without this extension, also the saved file hasn't this extension. Example-Code: QFileDialog fileDialog(this, "Choose file to save"); fileDialog.setNameFilter("PDF-Files (*.pdf)"); fileDialog.exec(); QFile pdfFile(fileDialog.selectedFiles().first()); now when the user enters "foo" as the name, the file will be saved as "foo", not as "foo.pdf". So the QFileDialog doesn't add the

Uploading .csv or .txt file to populate QTableView

*爱你&永不变心* 提交于 2019-12-09 13:38:21
问题 Recently I was working on a gui application & I wanted to save the data of QTableView in a .csv or .txt file. I Used the guidance received during this question which made me think if the reverse is also possible; i.e. if the QTableView can be populated from a .csv or .txt file. Once again I would prefer staying with a model based design such as QTableView instead of item based QTableWidget. Any code-snippet or tutorial-documentation would be really helpful. 回答1: Consider a test.csv file (it

how to use QWebPage in a non-GUI application

China☆狼群 提交于 2019-12-09 13:35:25
问题 I want to use QWebPage in a non-GUI Qt application. By that, I mean that I don't want to communicate with the window server at all. Using QtGui is not a problem, though. QWebPage internally creates some QWidget instances. Thus, using QCoreApplication is not possible. When creating a QApplication instance though, I already immediately get a MacOSX dock icon. And I don't want that. It also means that it somehow registers itself in Cocoa as a GUI application. My question is not Mac-only. I would

Qt - How to associate data with QTableWidgetItem?

强颜欢笑 提交于 2019-12-09 11:13:45
问题 I want to associate additional data with each QTableWidgetItem inserted into the table, in order to use that data in future, when it is being clicked on a table item. But that data should not be visible. How can I do that? 回答1: You can use QTableWidgetItem::setData() like so: setData(Qt::UserRole, myData); // set Where myData is a supported QVariant type. You can use QTableWidgetItem::data() to retrieve the value that you store. If you need more than one you can use Qt::UserRole + 1, + 2, and

Import .csv file to sqlite3 database table on QT gui

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-09 07:06:53
问题 I am writing a QT GUI application that will import a .csv file to a sqlite database table my .csv file is in the path /home/aj/import_table.csv and my database is in /home/aj/testdatabase.db i wrote the below code block--- void MainWindow::on_importButton_clicked() { QSqlDatabase db=QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName("/home/aj/testdatabase.db"); QString querystr; querystr=QString(".separator ",""); QSqlQuery query(querystr,db); if(query.exec()) { qDebug()<<"SUCCESSFULLY

Proper way to handle the close button in a main window PyQt, (Red “X”)

只谈情不闲聊 提交于 2019-12-09 06:23:36
问题 First off, I am a complete newbie to PyQt. I have been trying to link a function to the Main Window's close button (the red x in the corner of the window) but I haven't been having any success. Right now, my code looks something like this: class Ui_MainWindow(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) self.setupUi(self) def setupUi(self, MainWindow): #setup code goes here def retranslateUi(self, MainWindow): #re translation of the GUI code def closeEvent(self,

QDockWidget causes qt to crash

只愿长相守 提交于 2019-12-08 21:53:50
问题 I Have the version of Qt that is built into ubuntu 11.10. And am trying to use a QDockWidget that cannot actually dock (basically, I just want a window that floats. I don't want to just make the view be a top level view because then I would have the OS window bar up there, which I don't want, and if I were to hide it, then the window won't be movable). So, I basically make a new Qt Gui project, and don't change any of the files, except for the mainwindow.cpp file, which I change to: #include

QTableView sorting signal?

陌路散爱 提交于 2019-12-08 20:03:45
问题 I use QTableView + QStandardItemModel to show some data (data stored in some other data structure), and this table view is sortable . Since it is sortable, when sorting this model, I also need to sort the order of stored data. I try to implement a slot for the sorting signal, but I don't know what signal is emitted when clicking the header to start the sorting action. I tried the clicked signal, but it's only emitted for data row, not for the headerData. what should I do if I want to do

What is the right way to include Qt headers?

走远了吗. 提交于 2019-12-08 19:37:46
问题 So far I know several ways to #include Qt classes: #include <QtModule> This brings all classes of a specific module, for example QDomDocument , QDomElement , QDomNode and numerous others from #include <QtXml> . #include <QClassName> This adds declaration of a specific class one may want to use, e.g. QEvent , QStringList , QFile . #include <qcstyleheader.h> This has effect of the previous method, except for differently looking header name. So I wonder, are there any other ways to #include Qt