qt4

Qt - How to convert from QObject to UI elements?

半腔热情 提交于 2020-01-30 06:14:26
问题 I am working in Qt 4.7, and I have a QWidget object in my dialog. I need to go through each of the children and extract the current text into a QStringList. Every other object is a QCheckBox, and the rest are QComboBoxes (I would just need the text portion of both). So far the only way I could think of to do this would be to use the children() function to get them as QObject*'s and cast them, like this: QStringList textlist; for(int i = 0; i < ui->myWidget->children().size(); i++) { if(i % 2

How to insert QPushButton into TableView?

▼魔方 西西 提交于 2020-01-29 14:29:32
问题 I am implementing QAbstractTableModel and I would like to insert a QPushButton in the last column of each row. When users click on this button, a new window is shown with more information about this row. Do you have any idea how to insert the button? I know about delegating system but all examples are only about "how to edit color with the combo box"... 回答1: The model-view architecture isn't made to insert widgets into different cells, but you can draw the push button within the cell. The

QImage/QPixmap size limitations?

此生再无相见时 提交于 2020-01-28 01:50:49
问题 Are there any known size/space limitation of QPixmap and/or QImage objects documented? I did not find any useful information regarding this. I'm currently using Qt 4.7.3 on OSX and Windows. Particulary I'm interested in: Width/Height limits? Limits depending on color format? Difference between 32/64 bit machines? Difference regarding OS? I would naively suspect that memory is the only limitation, so one could calculate max size by width x height x byte_per_pixel I assume that there is a more

Warning when connecting c++ signal to qml slot

半腔热情 提交于 2020-01-25 15:50:05
问题 I connect a c++ signal to qml function in qt4.8.4. It's working fine but makes warning in application output as below: Object::connect: No such slot QDeclarativeItem_QML_9::onValue_changed(double) Object::connect: (sender name: 'MyWidget') I have defined qml slot like this : import QtQuick 1.0 Item { id: root property real value : 0 Connections { target: controllerObject onValue_changed : { root.value = value } } } And this is my c++ Signal and how it is connected to qml slot : ui->view-

Qt resize widget inside another widget

戏子无情 提交于 2020-01-25 03:29:06
问题 I have the following layout: The black rectangles are QVBoxLayouts, the red one is a generic widget container and the blue little rectangle is my custom openGL widget. I already set the resize policies for all layouts and widgets, but I can't get the openGL little widget to resize to the extent of his parent's area (the red rectangle in the image). I'm a Qt beginner, perhaps I need to use signals and slots to resize the little blue openGL widget to the red one? But how? 回答1: The QGLWidget

Change color of purple tab text in Konsole CSS

倖福魔咒の 提交于 2020-01-24 19:51:26
问题 When input comes in on a tab that is not active, the text for the tab changes to a purple color. What CSS selectors do I need to use to change this? I am using a custom stylesheet in Konsole to change how the tabs look, but can't figure out how to change this one value. This page makes no mention of it. I'm using Konsole 2.13.2(KDE 4.13.3) on Xubuntu 14.04(XFCE). 回答1: As of today, this tab-activity color appears to be set by void TabbedViewContainer::setTabActivity(int index , bool activity)

Connecting two different widgets together on qt with python through a button

故事扮演 提交于 2020-01-22 03:42:06
问题 I was wondering how to connect two widgets together. I have two widgets i created on QtDesigner, one being a Login page, and another being a Main Menu. I want to connect them so that when the Login is successful, the user will be redirected to the Main Window, and the Login widget will close automatically. Does anyone know how to do this? PS. I have the code for the main menu and login in separate .py files 回答1: You could do the following: In your QApp create first a dialogue containing the

Qt how to capture event indicating that all gui elements are ready

最后都变了- 提交于 2020-01-21 06:54:30
问题 I'm wondering if it is possible to capture an event that is generated when all Qt objects are initialized and ready ? It seems that some things can't be done in window's constructor. And they work fine in slot implementation. For example, when I want to access root window of my application I do it like that // in *.h MainWindow* rootWindow // in *.cpp rootWindow = qobject_cast<MainWindow *>(this->window()); If it is done in the contructor I can't use rootWindow object - it couses runtime

Intercepting Tab key press to manage focus switching manually

被刻印的时光 ゝ 提交于 2020-01-20 04:18:55
问题 I want to intercept Tab key press in my main window to prevent Qt from switching focus. Here's what I've tried so far: bool CMainWindow::event(QEvent * e) { if (e && e->type() == QEvent::KeyPress) { QKeyEvent * keyEvent = dynamic_cast<QKeyEvent*>(e); if (keyEvent && keyEvent->key() == Qt::Key_Tab) return true; } return QMainWindow::event(e); } This doesn't work, event isn't called when I press Tab . How to achieve what I want? 回答1: The most elegant way I found to avoid focus change is to

QDevelop Qt IDE in Ubuntu 10.04 LTS Lucid Lynx qwt

China☆狼群 提交于 2020-01-17 15:17:29
问题 I am having an issue using the QDevelop, Qt IDE (Qt version 4.6.2) in Ubuntu 10.04 LTS Lucid Lynx. The code I am trying to work with was transfered from a newer 64bit laptop to my 32 bit laptop. Both systems are running the same version of Ubuntu and Qt IDE. When I try building the code I get a long list of errors, which I don't really want to post here but I will at the end of my text. Any help would be greatly appreciated. For whatever reason, my blocks of text are getting cut off. I am